|
|
@@ -107,18 +107,37 @@ export class RelationsService {
|
|
|
return permission;
|
|
|
}
|
|
|
|
|
|
+ allowedRelations:Relation[];
|
|
|
+
|
|
|
+ disallowedGrowiUrls: Set<string>;
|
|
|
+
|
|
|
+ notAllowedCommandName:string
|
|
|
+
|
|
|
+ getAllowedRelations():Relation[] {
|
|
|
+ return this.allowedRelations;
|
|
|
+ }
|
|
|
+
|
|
|
+ getDisallowedGrowiUrls():Set<string> {
|
|
|
+ return this.disallowedGrowiUrls;
|
|
|
+ }
|
|
|
+
|
|
|
+ getNotAllowedCommandName():string {
|
|
|
+ return this.notAllowedCommandName;
|
|
|
+ }
|
|
|
|
|
|
async checkPermissionForInteractions(
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
relation:Relation, channelName:string, callbackId:string, actionId:string,
|
|
|
- ):Promise<{isPermittedForInteractions:boolean, commandName:string}> {
|
|
|
+ ):Promise<void> {
|
|
|
|
|
|
- let isPermittedForInteractions = false;
|
|
|
- let permissionForInteractions:boolean|string[];
|
|
|
+ // initialize params
|
|
|
+ this.allowedRelations = [];
|
|
|
+ this.disallowedGrowiUrls = new Set();
|
|
|
+ this.notAllowedCommandName = '';
|
|
|
|
|
|
+ let permissionForInteractions:boolean|string[];
|
|
|
const singleUse = Object.keys(relation.permissionsForSingleUseCommands);
|
|
|
const broadCastUse = Object.keys(relation.permissionsForBroadcastUseCommands);
|
|
|
- let commandName!:string;
|
|
|
|
|
|
[...singleUse, ...broadCastUse].forEach(async(tempCommandName) => {
|
|
|
|
|
|
@@ -129,27 +148,25 @@ export class RelationsService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- commandName = tempCommandName;
|
|
|
-
|
|
|
// case: singleUse
|
|
|
permissionForInteractions = relation.permissionsForSingleUseCommands[tempCommandName];
|
|
|
// case: broadcastUse
|
|
|
if (permissionForInteractions == null) {
|
|
|
permissionForInteractions = relation.permissionsForBroadcastUseCommands[tempCommandName];
|
|
|
}
|
|
|
+
|
|
|
if (permissionForInteractions === true) {
|
|
|
- isPermittedForInteractions = true;
|
|
|
- return;
|
|
|
+ return this.allowedRelations.push(relation);
|
|
|
}
|
|
|
+
|
|
|
// check permission at channel level
|
|
|
if (Array.isArray(permissionForInteractions) && permissionForInteractions.includes(channelName)) {
|
|
|
- isPermittedForInteractions = true;
|
|
|
- return;
|
|
|
+ return this.allowedRelations.push(relation);
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
-
|
|
|
- return { isPermittedForInteractions, commandName };
|
|
|
+ this.disallowedGrowiUrls.add(relation.growiUri);
|
|
|
+ this.notAllowedCommandName = tempCommandName;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
}
|