Procházet zdrojové kódy

shared functionalize in slack.js

zahmis před 5 roky
rodič
revize
832933284d
1 změnil soubory, kde provedl 7 přidání a 8 odebrání
  1. 7 8
      src/server/util/slack.js

+ 7 - 8
src/server/util/slack.js

@@ -88,7 +88,7 @@ module.exports = function(crowi) {
     return body;
     return body;
   };
   };
 
 
-  const prepareSlackMessageForPage = function(page, user, channel, updateType, previousRevision) {
+  slack.prepareSlackMessageForPage = (page, user, channel, updateType, previousRevision) => {
     const appTitle = crowi.appService.getAppTitle();
     const appTitle = crowi.appService.getAppTitle();
     const url = crowi.appService.getSiteUrl();
     const url = crowi.appService.getSiteUrl();
     let body = page.revision.body;
     let body = page.revision.body;
@@ -124,7 +124,7 @@ module.exports = function(crowi) {
     return message;
     return message;
   };
   };
 
 
-  const prepareSlackMessageForComment = function(comment, user, channel, path) {
+  slack.prepareSlackMessageForComment = (comment, user, channel, path) => {
     const appTitle = crowi.appService.getAppTitle();
     const appTitle = crowi.appService.getAppTitle();
     const url = crowi.appService.getSiteUrl();
     const url = crowi.appService.getSiteUrl();
     const body = prepareAttachmentTextForComment(comment);
     const body = prepareAttachmentTextForComment(comment);
@@ -158,7 +158,7 @@ module.exports = function(crowi) {
    * @param {string} attachmentBody
    * @param {string} attachmentBody
    * @param {string} slackChannel
    * @param {string} slackChannel
   */
   */
-  const prepareSlackMessageForGlobalNotification = async(messageBody, attachmentBody, slackChannel) => {
+  slack.prepareSlackMessageForGlobalNotification = async(messageBody, attachmentBody, slackChannel) => {
     const appTitle = crowi.appService.getAppTitle();
     const appTitle = crowi.appService.getAppTitle();
 
 
     const attachment = {
     const attachment = {
@@ -200,26 +200,25 @@ module.exports = function(crowi) {
     return text;
     return text;
   };
   };
 
 
-  // slack.post = function (channel, message, opts) {
   slack.postPage = (page, user, channel, updateType, previousRevision) => {
   slack.postPage = (page, user, channel, updateType, previousRevision) => {
-    const messageObj = prepareSlackMessageForPage(page, user, channel, updateType, previousRevision);
+    const messageObj = slack.prepareSlackMessageForPage(page, user, channel, updateType, previousRevision);
 
 
     return slackPost(messageObj);
     return slackPost(messageObj);
   };
   };
 
 
   slack.postComment = (comment, user, channel, path) => {
   slack.postComment = (comment, user, channel, path) => {
-    const messageObj = prepareSlackMessageForComment(comment, user, channel, path);
+    const messageObj = slack.prepareSlackMessageForComment(comment, user, channel, path);
 
 
     return slackPost(messageObj);
     return slackPost(messageObj);
   };
   };
 
 
   slack.sendGlobalNotification = async(messageBody, attachmentBody, slackChannel) => {
   slack.sendGlobalNotification = async(messageBody, attachmentBody, slackChannel) => {
-    const messageObj = await prepareSlackMessageForGlobalNotification(messageBody, attachmentBody, slackChannel);
-
+    const messageObj = await slack.prepareSlackMessageForGlobalNotification(messageBody, attachmentBody, slackChannel);
     return slackPost(messageObj);
     return slackPost(messageObj);
   };
   };
 
 
   const slackPost = (messageObj) => {
   const slackPost = (messageObj) => {
+    console.log('hoge');
     // when incoming Webhooks is prioritized
     // when incoming Webhooks is prioritized
     if (configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized')) {
     if (configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized')) {
       // if (configManager.getConfig('notification', 'slack:incomingWebhookUrl')) {
       // if (configManager.getConfig('notification', 'slack:incomingWebhookUrl')) {