itizawa 4 ani în urmă
părinte
comite
84297eb151

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

@@ -170,7 +170,7 @@ export class GrowiToSlackCtrl {
     logger.debug('relation test is success', order);
 
     // Transaction is not considered because it is used infrequently,
-    await this.relationRepository.createQueryBuilder('relation')
+    const response = await this.relationRepository.createQueryBuilder('relation')
       .insert()
       .values({
         installation: order.installation,
@@ -179,10 +179,14 @@ export class GrowiToSlackCtrl {
         growiUri: order.growiUrl,
         siglePostCommands: temporarySinglePostCommands,
       })
+      // https://github.com/typeorm/typeorm/issues/1090#issuecomment-634391487
       .orUpdate({ conflict_target: ['installation', 'growiUri'], overwrite: ['tokenGtoP', 'tokenPtoG', 'siglePostCommands'] })
       .execute();
 
-    return res.send({ slackBotToken: token });
+    // Find the generated relation
+    const generatedRelation = await this.relationRepository.findOne({ id: response.identifiers[0].id });
+
+    return res.send({ relation: generatedRelation, slackBotToken: token });
   }
 
   injectGrowiUri(req: GrowiReq, growiUri: string): void {