sou 7 лет назад
Родитель
Сommit
5d8f1c5f7b
2 измененных файлов с 25 добавлено и 1 удалено
  1. 3 1
      lib/routes/comment.js
  2. 22 0
      lib/routes/slack.js

+ 3 - 1
lib/routes/comment.js

@@ -5,6 +5,7 @@ module.exports = function(crowi, app) {
     , Comment = crowi.model('Comment')
     , Comment = crowi.model('Comment')
     , Page = crowi.model('Page')
     , Page = crowi.model('Page')
     , ApiResponse = require('../util/apiResponse')
     , ApiResponse = require('../util/apiResponse')
+    , slack = require('./slack')
     , actions = {}
     , actions = {}
     , api = {};
     , api = {};
 
 
@@ -73,7 +74,8 @@ module.exports = function(crowi, app) {
       lastUpdateUser: req.user,
       lastUpdateUser: req.user,
       updatedAt: new Date()
       updatedAt: new Date()
     });
     });
-
+    const s = new slack('adsf');
+    await s.send();
     return res.json(ApiResponse.success({comment: createdComment}));
     return res.json(ApiResponse.success({comment: createdComment}));
   };
   };
 
 

+ 22 - 0
lib/routes/slack.js

@@ -0,0 +1,22 @@
+module.exports = function(text) {
+  const slackFunc = {};
+  slackFunc.send = function(text) {
+    const Slack = require('slack-node');
+
+    const webhookUri = 'https://hooks.slack.com/services/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 ';
+
+    const slack = new Slack();
+    slack.setWebhook(webhookUri);
+
+    slack.webhook({
+      channel: '#general',
+      username: 'Growi',
+      text: '`comment uploaded`'
+    }, function(err, response) {
+      console.log(response);
+    });
+    console.log('i\'m in: text is: ', text);
+  };
+
+  return slackFunc;
+};