From 117e6a43b7ecc22f051c80cc980b32b0a8a6e076 Mon Sep 17 00:00:00 2001 From: Jan Thijs <92784122+janthijs@users.noreply.github.com> Date: Tue, 3 Oct 2023 14:51:38 +0200 Subject: [PATCH] try this --- scripts/release-notifications/echo.js | 54 ++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/scripts/release-notifications/echo.js b/scripts/release-notifications/echo.js index 8ef2c760b3..aff34993ee 100644 --- a/scripts/release-notifications/echo.js +++ b/scripts/release-notifications/echo.js @@ -1,6 +1,56 @@ const args = process.argv.slice(2); -const WEBHOOK = args[0].split('=')[1]; +const PATH = args[0].split('=')[1]; const HOST = args[1].split('=')[1]; -console.log(HOST, WEBHOOK); +const post_data = { + type: 'message', + attachments: [ + { + contentType: 'application/vnd.microsoft.card.adaptive', + content: { + type: 'AdaptiveCard', + body: [ + { + type: 'TextBlock', + text: 'Message Text', + }, + ], + $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', + version: '1.0', + }, + }, + ], +}; + +const post_options = { + host: HOST, + port: 443, + path: PATH, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(post_data), + 'User-Agent': 'nodejs', + }, +}; + +try { + // Set up the request + const post_req = https.request(post_options, function (res) { + res.setEncoding('utf8'); + res.on('error', function (err) { + console.error(err.stack); + console.log('Node NOT Exiting...'); + }); + res.on('data', function (chunk) { + console.log('Response: ' + chunk); + }); + }); + + post_req.write(post_data); + post_req.end(); +} catch (e) { + console.error(e); + console.log('Node NOT Exiting...'); +}