diff --git a/plugins/talk-plugin-slack-notifications/server/config.js b/plugins/talk-plugin-slack-notifications/server/config.js index 7571565b0..11f76f138 100644 --- a/plugins/talk-plugin-slack-notifications/server/config.js +++ b/plugins/talk-plugin-slack-notifications/server/config.js @@ -5,7 +5,9 @@ const config = { if (process.env.NODE_ENV !== 'test' && !config.SLACK_WEBHOOK_URL) { // TODO this error should point users to Talk's Slack app once that's in place - throw new Error('Please set the TALK_SLACK_WEBHOOK_URL environment variable to use the slack-notifications plugin.'); + throw new Error( + 'Please set the TALK_SLACK_WEBHOOK_URL environment variable to use the slack-notifications plugin.' + ); } module.exports = config; diff --git a/plugins/talk-plugin-slack-notifications/server/hooks.js b/plugins/talk-plugin-slack-notifications/server/hooks.js index bda9dc4f5..4133f795d 100644 --- a/plugins/talk-plugin-slack-notifications/server/hooks.js +++ b/plugins/talk-plugin-slack-notifications/server/hooks.js @@ -1,5 +1,5 @@ const fetch = require('node-fetch'); -const {SLACK_WEBHOOK_URL, SLACK_WEBHOOK_TIMEOUT} = require('./config'); +const { SLACK_WEBHOOK_URL, SLACK_WEBHOOK_TIMEOUT } = require('./config'); const debug = require('debug')('talk:plugin:slack-notifications'); // We don't add the hooks during _test_ as the Slack API is not available. @@ -10,14 +10,9 @@ if (process.env.NODE_ENV === 'test') { module.exports = { RootMutation: { createComment: { - async post(_, {input}, context, _info, result) { + async post(root, args, context, info, result) { debug(`Posting notification to Slack webhook: ${SLACK_WEBHOOK_URL}`); - const { - comment: { - body: text, - created_at: createdAt - } - } = result; + const { comment: { body: text, created_at: createdAt } } = result; const username = context.user.username; process.nextTick(async () => { const response = await fetch(SLACK_WEBHOOK_URL, { @@ -27,16 +22,22 @@ module.exports = { }, timeout: SLACK_WEBHOOK_TIMEOUT, body: JSON.stringify({ - attachments: [{ - text: text, - footer: `Comment by ${username}`, - ts: Math.floor(Date.parse(createdAt) / 1000), - }] + attachments: [ + { + text: text, + footer: `Comment by ${username}`, + ts: Math.floor(Date.parse(createdAt) / 1000), + }, + ], }), }); if (!response.ok) { const responseText = await response.text(); - console.trace(`Posting to Slack failed with HTTP code ${response.status} and body '${responseText}'`); + console.trace( + `Posting to Slack failed with HTTP code ${ + response.status + } and body '${responseText}'` + ); } }); return result;