瀏覽代碼

implement publishUpdatedMessage

itizawa 5 年之前
父節點
當前提交
1bccf3abaf
共有 2 個文件被更改,包括 18 次插入0 次删除
  1. 1 0
      src/server/routes/apiv3/slack-integration.js
  2. 17 0
      src/server/service/bolt.js

+ 1 - 0
src/server/routes/apiv3/slack-integration.js

@@ -126,6 +126,7 @@ module.exports = (crowi) => {
 
         // initialize bolt service
         crowi.boltService.initialize();
+        crowi.boltService.publishUpdatedMessage();
 
         // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
         const customBotNonProxySettingParams = {

+ 17 - 0
src/server/service/bolt.js

@@ -49,6 +49,7 @@ class BoltReciever {
 
 const { App } = require('@slack/bolt');
 const { WebClient, LogLevel } = require('@slack/web-api');
+const S2sMessage = require('../models/vo/s2s-message');
 
 class BoltService {
 
@@ -86,6 +87,22 @@ class BoltService {
     this.isBoltSetup = true;
   }
 
+  async publishUpdatedMessage() {
+    const { s2sMessagingService } = this;
+
+    if (s2sMessagingService != null) {
+      const s2sMessage = new S2sMessage('boltServiceUpdated', { updatedAt: new Date() });
+
+      try {
+        await s2sMessagingService.publish(s2sMessage);
+      }
+      catch (e) {
+        logger.error('Failed to publish update message with S2sMessagingService: ', e.message);
+      }
+    }
+  }
+
+
   setupRoute() {
     this.bolt.command('/growi', async({
       command, client, body, ack,