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

+ 3 - 2
lib/routes/comment.js

@@ -71,7 +71,7 @@ module.exports = function(crowi, app) {
       });
       });
 
 
     // update page
     // update page
-    await Page.findOneAndUpdate({ _id: pageId }, {
+    const page = await Page.findOneAndUpdate({ _id: pageId }, {
       lastUpdateUser: req.user,
       lastUpdateUser: req.user,
       updatedAt: new Date()
       updatedAt: new Date()
     });
     });
@@ -79,7 +79,8 @@ module.exports = function(crowi, app) {
     // slack notification
     // slack notification
     const slackNotify = new slack(crowi);
     const slackNotify = new slack(crowi);
     const user = await User.findUserByUsername(req.user.username);
     const user = await User.findUserByUsername(req.user.username);
-    await slackNotify.postComment(createdComment, user, 'general');
+    const path = page.path;
+    await slackNotify.postComment(createdComment, user, 'general', path);
 
 
     return res.json(ApiResponse.success({comment: createdComment}));
     return res.json(ApiResponse.success({comment: createdComment}));
   };
   };

+ 5 - 5
lib/util/slack.js

@@ -124,9 +124,9 @@ module.exports = function(crowi) {
     return message;
     return message;
   };
   };
 
 
-  const prepareSlackMessageForComment = function(comment, user, channel) {
+  const prepareSlackMessageForComment = function(comment, user, channel, path) {
     const url = config.crowi['app:url'] || '';
     const url = config.crowi['app:url'] || '';
-    const body = prepareAttachmentTextForComment(comment, user);
+    const body = prepareAttachmentTextForComment(comment);
 
 
     const attachment = {
     const attachment = {
       color: '#263a3c',
       color: '#263a3c',
@@ -143,7 +143,7 @@ module.exports = function(crowi) {
     const message = {
     const message = {
       channel: '#' + channel,
       channel: '#' + channel,
       username: Config.appTitle(config),
       username: Config.appTitle(config),
-      text: getSlackMessageTextForComment('what do i do with path', user),
+      text: getSlackMessageTextForComment(path, user),
       attachments: [attachment],
       attachments: [attachment],
     };
     };
 
 
@@ -180,8 +180,8 @@ module.exports = function(crowi) {
     return promisifiedSlackPost(messageObj);
     return promisifiedSlackPost(messageObj);
   };
   };
 
 
-  slack.postComment = (comment, user, channel) => {
-    const messageObj = prepareSlackMessageForComment(comment, user, channel);
+  slack.postComment = (comment, user, channel, path) => {
+    const messageObj = prepareSlackMessageForComment(comment, user, channel, path);
 
 
     return promisifiedSlackPost(messageObj);
     return promisifiedSlackPost(messageObj);
   };
   };