Przeglądaj źródła

Merge pull request #923 from weseek/imprv/share-slack-with-page-id-url

Imprv/share slack with page id url
Yuki Takei 7 lat temu
rodzic
commit
54a090a913
1 zmienionych plików z 6 dodań i 6 usunięć
  1. 6 6
      src/server/util/slack.js

+ 6 - 6
src/server/util/slack.js

@@ -134,7 +134,7 @@ module.exports = function(crowi) {
     const message = {
     const message = {
       channel: `#${channel}`,
       channel: `#${channel}`,
       username: Config.appTitle(config),
       username: Config.appTitle(config),
-      text: getSlackMessageTextForPage(page.path, user, updateType),
+      text: getSlackMessageTextForPage(page.path, page.id, user, updateType),
       attachments: [attachment],
       attachments: [attachment],
     };
     };
 
 
@@ -160,18 +160,18 @@ module.exports = function(crowi) {
     const message = {
     const message = {
       channel: `#${channel}`,
       channel: `#${channel}`,
       username: Config.appTitle(config),
       username: Config.appTitle(config),
-      text: getSlackMessageTextForComment(path, user),
+      text: getSlackMessageTextForComment(path, String(comment.page), user),
       attachments: [attachment],
       attachments: [attachment],
     };
     };
 
 
     return message;
     return message;
   };
   };
 
 
-  const getSlackMessageTextForPage = function(path, user, updateType) {
+  const getSlackMessageTextForPage = function(path, pageId, user, updateType) {
     let text;
     let text;
     const url = crowi.configManager.getSiteUrl();
     const url = crowi.configManager.getSiteUrl();
 
 
-    const pageUrl = `<${urljoin(url, path)}|${path}>`;
+    const pageUrl = `<${urljoin(url, pageId)}|${path}>`;
     if (updateType === 'create') {
     if (updateType === 'create') {
       text = `:rocket: ${user.username} created a new page! ${pageUrl}`;
       text = `:rocket: ${user.username} created a new page! ${pageUrl}`;
     }
     }
@@ -182,9 +182,9 @@ module.exports = function(crowi) {
     return text;
     return text;
   };
   };
 
 
-  const getSlackMessageTextForComment = function(path, user) {
+  const getSlackMessageTextForComment = function(path, pageId, user) {
     const url = crowi.configManager.getSiteUrl();
     const url = crowi.configManager.getSiteUrl();
-    const pageUrl = `<${urljoin(url, path)}|${path}>`;
+    const pageUrl = `<${urljoin(url, pageId)}|${path}>`;
     const text = `:speech_balloon: ${user.username} commented on ${pageUrl}`;
     const text = `:speech_balloon: ${user.username} commented on ${pageUrl}`;
 
 
     return text;
     return text;