zahmis 4 years ago
parent
commit
15848ba8a8

+ 2 - 2
packages/slackbot-proxy/src/controllers/slack.ts

@@ -337,12 +337,12 @@ export class SlackCtrl {
 
     const actionId:string = payload?.actions?.[0].action_id;
     const permission = await this.relationsService.checkPermissionForInteractions(relations, actionId, callbackId, channelName);
-    const { allowedRelations, disallowedGrowiUrls, notAllowedCommandName } = permission;
+    const { allowedRelations, disallowedGrowiUrls, commandName } = permission;
 
     if (relations.length === disallowedGrowiUrls.size) {
       // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
       const client = generateWebClient(authorizeResult.botToken!);
-      return postNotAllowedMessage(client, body, disallowedGrowiUrls, notAllowedCommandName);
+      return postNotAllowedMessage(client, body, disallowedGrowiUrls, commandName);
     }
 
     /*

+ 5 - 4
packages/slackbot-proxy/src/services/RelationsService.ts

@@ -14,7 +14,7 @@ const logger = loggerFactory('slackbot-proxy:services:RelationsService');
 type checkPermissionForInteractionsResults = {
   allowedRelations:Relation[],
   disallowedGrowiUrls:Set<string>,
-  notAllowedCommandName:string|null,
+  commandName:string,
 }
 
 @Service()
@@ -119,7 +119,7 @@ export class RelationsService {
 
     const allowedRelations:Relation[] = [];
     const disallowedGrowiUrls:Set<string> = new Set();
-    let notAllowedCommandName:string| null = null;
+    let commandName = '';
 
     await Promise.all(relations.map(async(relation) => {
       let permissionForInteractions:boolean|string[];
@@ -135,6 +135,8 @@ export class RelationsService {
           return;
         }
 
+        commandName = tempCommandName;
+
         // case: singleUse
         permissionForInteractions = relation.permissionsForSingleUseCommands[tempCommandName];
         // case: broadcastUse
@@ -152,12 +154,11 @@ export class RelationsService {
         }
 
         disallowedGrowiUrls.add(relation.growiUri);
-        notAllowedCommandName = tempCommandName;
       });
 
     }));
 
-    return { allowedRelations, disallowedGrowiUrls, notAllowedCommandName };
+    return { allowedRelations, disallowedGrowiUrls, commandName };
 
   }