zahmis 4 лет назад
Родитель
Сommit
cbbc111136

+ 11 - 1
packages/slackbot-proxy/src/controllers/slack.ts

@@ -333,7 +333,17 @@ export class SlackCtrl {
 
     const actionId:string = payload?.actions?.[0].action_id;
     const permission = await this.relationsService.checkPermissionForInteractions(relations, actionId, callbackId, channelName);
-    const { allowedRelations, disallowedGrowiUrls, commandName } = permission;
+    const {
+      allowedRelations, disallowedGrowiUrls, commandName, rejectedResults,
+    } = permission;
+
+    try {
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+      await postEphemeralErrors(rejectedResults, body.channel_id, body.user_id, authorizeResult.botToken!);
+    }
+    catch (err) {
+      logger.error(err);
+    }
 
     if (relations.length === disallowedGrowiUrls.size) {
       // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

+ 8 - 3
packages/slackbot-proxy/src/services/RelationsService.ts

@@ -15,6 +15,7 @@ type checkPermissionForInteractionsResults = {
   allowedRelations:Relation[],
   disallowedGrowiUrls:Set<string>,
   commandName:string,
+  rejectedResults:PromiseRejectedResult[]
 }
 
 @Service()
@@ -127,7 +128,7 @@ export class RelationsService {
     const disallowedGrowiUrls:Set<string> = new Set();
     let commandName = '';
 
-    await relations.map(async(relation) => {
+    const results = await Promise.allSettled(relations.map(async(relation) => {
       let permissionForInteractions:boolean|string[];
       const singleUse = Object.keys(relation.permissionsForSingleUseCommands);
       const broadCastUse = Object.keys(relation.permissionsForBroadcastUseCommands);
@@ -161,10 +162,14 @@ export class RelationsService {
 
         disallowedGrowiUrls.add(relation.growiUri);
       });
+    }));
+
+    const rejectedResults: PromiseRejectedResult[] = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected');
 
-    });
 
-    return { allowedRelations, disallowedGrowiUrls, commandName };
+    return {
+      allowedRelations, disallowedGrowiUrls, commandName, rejectedResults,
+    };
   }
 
 }