Răsfoiți Sursa

rename SlackBotService -> SlackIntegrationService

Yuki Takei 4 ani în urmă
părinte
comite
4c471425b4

+ 7 - 7
packages/app/src/server/crowi/index.js

@@ -15,6 +15,7 @@ import { projectRoot } from '~/utils/project-dir-utils';
 import ConfigManager from '../service/config-manager';
 import AclService from '../service/acl';
 import AttachmentService from '../service/attachment';
+import { SlackIntegrationService } from '../service/slack-integration';
 
 const logger = loggerFactory('growi:crowi');
 const httpErrorHandler = require('../middlewares/http-error-handler');
@@ -60,7 +61,7 @@ function Crowi() {
   this.syncPageStatusService = null;
   this.cdnResourcesService = new CdnResourcesService();
   this.interceptorManager = new InterceptorManager();
-  this.slackBotService = null;
+  this.slackIntegrationService = null;
   this.xss = new Xss();
 
   this.tokens = null;
@@ -121,7 +122,7 @@ Crowi.prototype.init = async function() {
     this.setupImport(),
     this.setupPageService(),
     this.setupSyncPageStatusService(),
-    this.setupSlackBotService(),
+    this.setupSlackIntegrationService(),
   ]);
 
   // globalNotification depends on slack and mailer
@@ -681,15 +682,14 @@ Crowi.prototype.setupSyncPageStatusService = async function() {
   }
 };
 
-Crowi.prototype.setupSlackBotService = async function() {
-  const SlackBotService = require('../service/slackbot');
-  if (this.slackBotService == null) {
-    this.slackBotService = new SlackBotService(this);
+Crowi.prototype.setupSlackIntegrationService = async function() {
+  if (this.slackIntegrationService == null) {
+    this.slackIntegrationService = new SlackIntegrationService(this);
   }
 
   // add as a message handler
   if (this.s2sMessagingService != null) {
-    this.s2sMessagingService.addMessageHandler(this.slackBotService);
+    this.s2sMessagingService.addMessageHandler(this.slackIntegrationService);
   }
 };
 

+ 5 - 5
packages/app/src/server/routes/apiv3/slack-integration-settings.js

@@ -246,7 +246,7 @@ module.exports = (crowi) => {
 
     try {
       await updateSlackBotSettings(requestParams);
-      crowi.slackBotService.publishUpdatedMessage();
+      crowi.slackIntegrationService.publishUpdatedMessage();
 
       const slackIntegrationSettingsParams = {
         currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
@@ -292,7 +292,7 @@ module.exports = (crowi) => {
 
     try {
       await updateSlackBotSettings(requestParams);
-      crowi.slackBotService.publishUpdatedMessage();
+      crowi.slackIntegrationService.publishUpdatedMessage();
 
       // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
       const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
@@ -330,7 +330,7 @@ module.exports = (crowi) => {
 
     try {
       await updateSlackBotSettings(params);
-      crowi.slackBotService.publishUpdatedMessage();
+      crowi.slackIntegrationService.publishUpdatedMessage();
 
       // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
       const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
@@ -370,7 +370,7 @@ module.exports = (crowi) => {
     };
     try {
       await updateSlackBotSettings(requestParams);
-      crowi.slackBotService.publishUpdatedMessage();
+      crowi.slackIntegrationService.publishUpdatedMessage();
 
       const customBotWithoutProxySettingParams = {
         slackSigningSecret: crowi.configManager.getConfig('crowi', 'slackbot:signingSecret'),
@@ -488,7 +488,7 @@ module.exports = (crowi) => {
 
     try {
       await updateSlackBotSettings(requestParams);
-      crowi.slackBotService.publishUpdatedMessage();
+      crowi.slackIntegrationService.publishUpdatedMessage();
       return res.apiv3({});
     }
     catch (error) {

+ 3 - 3
packages/app/src/server/routes/apiv3/slack-integration.js

@@ -154,7 +154,7 @@ module.exports = (crowi) => {
     const command = args[0];
 
     try {
-      await crowi.slackBotService.handleCommandRequest(command, client, body, args);
+      await crowi.slackIntegrationService.handleCommandRequest(command, client, body, args);
     }
     catch (err) {
       await respondIfSlackbotError(client, body, err);
@@ -203,7 +203,7 @@ module.exports = (crowi) => {
       switch (type) {
         case 'block_actions':
           try {
-            await crowi.slackBotService.handleBlockActionsRequest(client, payload);
+            await crowi.slackIntegrationService.handleBlockActionsRequest(client, payload);
           }
           catch (err) {
             await respondIfSlackbotError(client, req.body, err);
@@ -211,7 +211,7 @@ module.exports = (crowi) => {
           break;
         case 'view_submission':
           try {
-            await crowi.slackBotService.handleViewSubmissionRequest(client, payload);
+            await crowi.slackIntegrationService.handleViewSubmissionRequest(client, payload);
           }
           catch (err) {
             await respondIfSlackbotError(client, req.body, err);

+ 3 - 5
packages/app/src/server/service/slackbot.ts → packages/app/src/server/service/slack-integration.ts

@@ -9,7 +9,7 @@ const { markdownSectionBlock } = require('@growi/slack');
 const S2sMessage = require('../models/vo/s2s-message');
 
 
-class SlackBotService implements S2sMessageHandlable {
+export class SlackIntegrationService implements S2sMessageHandlable {
 
   crowi!: any;
 
@@ -33,7 +33,7 @@ class SlackBotService implements S2sMessageHandlable {
    */
   shouldHandleS2sMessage(s2sMessage) {
     const { eventName, updatedAt } = s2sMessage;
-    if (eventName !== 'slackBotServiceUpdated' || updatedAt == null) {
+    if (eventName !== 'slackIntegrationServiceUpdated' || updatedAt == null) {
       return false;
     }
 
@@ -56,7 +56,7 @@ class SlackBotService implements S2sMessageHandlable {
     const { s2sMessagingService } = this;
 
     if (s2sMessagingService != null) {
-      const s2sMessage = new S2sMessage('slackBotServiceUpdated', { updatedAt: new Date() });
+      const s2sMessage = new S2sMessage('slackIntegrationServiceUpdated', { updatedAt: new Date() });
 
       try {
         await s2sMessagingService.publish(s2sMessage);
@@ -132,5 +132,3 @@ class SlackBotService implements S2sMessageHandlable {
   }
 
 }
-
-module.exports = SlackBotService;