Skip to content

Commit

Permalink
Update Slack support for payloads.
Browse files Browse the repository at this point in the history
  • Loading branch information
avaidyam committed Mar 31, 2021
1 parent 034fbb8 commit 1bc305b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async function SNSpush(number, payload) {
// Send a Slack message to a predefined channel/webhook.
async function SLACKpush(hook, message) {
const client = http2.connect(`https://hooks.slack.com:443`)
const buffer = Buffer.from(JSON.stringify({ text: message }))
const buffer = Buffer.from(JSON.stringify({ text: message.content || "<no message body>" }))
const request = client.request({
[':method']: 'POST',
[':path']: `/services/${hook}`,
Expand Down Expand Up @@ -235,7 +235,7 @@ app.put(['/log', '/'], express.text({type: '*/*'}), async (req, res) => {

// Shortcut for sending a slack message instead of a log. [DEPRECATED]
if (req.query.stream === 'slack') {
let q = await SLACKpush(SLACK_HOOK, (req.body || '').trim())
let q = await SLACKpush(SLACK_HOOK, { content: (req.body || '').trim() })
return res.status(200).json({ "destination": "slack" })
} else {
console.log(`[${req.query.level || 'info'}] [${req.query.origin || 'unknown'}] ${(req.body || '').trim()}`)
Expand Down

0 comments on commit 1bc305b

Please sign in to comment.