Explorar o código

implement publishUpdatedMessage

itizawa %!s(int64=5) %!d(string=hai) anos
pai
achega
1bccf3abaf
Modificáronse 2 ficheiros con 18 adicións e 0 borrados
  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
         // initialize bolt service
         crowi.boltService.initialize();
         crowi.boltService.initialize();
+        crowi.boltService.publishUpdatedMessage();
 
 
         // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
         // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
         const customBotNonProxySettingParams = {
         const customBotNonProxySettingParams = {

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

@@ -49,6 +49,7 @@ class BoltReciever {
 
 
 const { App } = require('@slack/bolt');
 const { App } = require('@slack/bolt');
 const { WebClient, LogLevel } = require('@slack/web-api');
 const { WebClient, LogLevel } = require('@slack/web-api');
+const S2sMessage = require('../models/vo/s2s-message');
 
 
 class BoltService {
 class BoltService {
 
 
@@ -86,6 +87,22 @@ class BoltService {
     this.isBoltSetup = true;
     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() {
   setupRoute() {
     this.bolt.command('/growi', async({
     this.bolt.command('/growi', async({
       command, client, body, ack,
       command, client, body, ack,