Taichi Masuyama 4 lat temu
rodzic
commit
f506b1510b

+ 2 - 3
packages/app/src/server/models/slack-app-integration-mock.js

@@ -9,9 +9,8 @@ const permittedChannelsForEachCommandSchema = new mongoose.Schema({
 const schema = new mongoose.Schema({
   tokenGtoP: { type: String, required: true, unique: true },
   tokenPtoG: { type: String, required: true, unique: true },
-  supportedCommandsForBroadcastUse: { type: [String], default: [] },
-  supportedCommandsForSingleUse: { type: [String], default: [] },
-  permittedChannelsForEachCommand: permittedChannelsForEachCommandSchema,
+  permissionsForBroadcastUseCommands: Map,
+  permissionsForSingleUseCommands: Map,
 });
 
 class SlackAppIntegrationMock {

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

@@ -420,14 +420,19 @@ module.exports = (crowi) => {
        * this code represents the creation of new SlackAppIntegration model
        */
       const SlackAppIntegrationMock = mongoose.model('SlackAppIntegrationMock');
+      const initialSupportedCommandsForBroadcastUse = new Map();
+      const initialSupportedCommandsForSingleUse = new Map();
+      defaultSupportedCommandsNameForBroadcastUse.forEach((commandName) => {
+        initialSupportedCommandsForBroadcastUse.set(commandName, true);
+      });
+      defaultSupportedCommandsNameForSingleUse.forEach((commandName) => {
+        initialSupportedCommandsForSingleUse.set(commandName, true);
+      });
       const MOCK = await SlackAppIntegrationMock.create({
         tokenGtoP,
         tokenPtoG,
-        supportedCommandsForBroadcastUse: defaultSupportedCommandsNameForBroadcastUse,
-        supportedCommandsForSingleUse: defaultSupportedCommandsNameForSingleUse,
-        permittedChannelsForEachCommand: {
-          channelsObject: new Map(),
-        },
+        permissionsForBroadcastUseCommands: initialSupportedCommandsForBroadcastUse,
+        permissionsForSingleUseCommands: initialSupportedCommandsForSingleUse,
       });
       // MOCK DATA DELETE THIS GW-6972 ---------------
       return res.apiv3(slackAppTokens, 200);

+ 5 - 8
packages/slackbot-proxy/src/entities/relation-mock.ts

@@ -10,8 +10,8 @@ import { Installation } from './installation';
 //     create: ['srv', 'admin'],
 //     search: ['admin'],
 //   }
-interface PermittedChannelsForEachCommand {
-  channelsObject: { [command: string]: string[] }
+interface PermissionSettingsInterface {
+  [commandName: string]: boolean | string[],
 }
 
 @Entity()
@@ -41,14 +41,11 @@ export class RelationMock {
   @Column()
   growiUri: string;
 
-  @Column('simple-array')
-  supportedCommandsForBroadcastUse: string[];
-
-  @Column('simple-array')
-  supportedCommandsForSingleUse: string[];
+  @Column({ type: 'json' })
+  permissionsForBroadcastUseCommands: PermissionSettingsInterface;
 
   @Column({ type: 'json' })
-  permittedChannelsForEachCommand : PermittedChannelsForEachCommand
+  permissionsForSingleUseCommands: PermissionSettingsInterface;
 
   @Column({ type: 'timestamp' })
   expiredAtCommands: Date;