Răsfoiți Sursa

implement postMessage

itizawa 4 ani în urmă
părinte
comite
90e301ff18
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      src/server/util/slack.js

+ 3 - 2
src/server/util/slack.js

@@ -9,6 +9,7 @@ const urljoin = require('url-join');
 
 module.exports = function(crowi) {
   const Slack = require('slack-node');
+  const { WebClient } = require('@slack/web-api');
   const { configManager } = crowi;
 
   const slack = {};
@@ -30,12 +31,12 @@ module.exports = function(crowi) {
 
   const postWithWebApi = function(messageObj) {
     return new Promise((resolve, reject) => {
-      const client = new Slack(configManager.getConfig('notification', 'slack:token'));
+      const client = new WebClient(configManager.getConfig('notification', 'slack:token'));
       // stringify attachments
       if (messageObj.attachments != null) {
         messageObj.attachments = JSON.stringify(messageObj.attachments);
       }
-      client.api('chat.postMessage', messageObj, (err, res) => {
+      client.chat.postMessage(messageObj, (err, res) => {
         if (err) {
           debug('Post error', err, res);
           debug('Sent data to slack is:', messageObj);