Skip to content

Commit 21b079b

Browse files
committed
fix: cancel all copilot requests for a project when manually copilot is added
1 parent 724d028 commit 21b079b

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/routes/projectMemberInvites/update.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,38 @@ module.exports = [
213213
transaction: t,
214214
});
215215

216+
const copilotApplications = await models.CopilotApplication.findAll({
217+
where: {
218+
opportunityId: {
219+
[Op.in]: allCopilotOpportunityByRequestIds.map(item => item.id),
220+
},
221+
},
222+
transaction: t,
223+
});
224+
216225
await models.CopilotApplication.update({
217226
status: COPILOT_APPLICATION_STATUS.CANCELED,
218227
}, {
219228
where: {
220-
opportunityId: {
221-
[Op.in]: allCopilotOpportunityByRequestIds.map(item => item.id),
229+
id: {
230+
[Op.in]: copilotApplications.map(item => item.id),
222231
},
223232
},
224233
transaction: t,
225234
});
235+
236+
// Cancel the existing invites which are opened via
237+
// applications
238+
await models.ProjectMemberInvite.update({
239+
status: INVITE_STATUS.CANCELED,
240+
}, {
241+
where: {
242+
applicationId: {
243+
[Op.in]: copilotApplications.map(item => item.id),
244+
}
245+
},
246+
transaction: t,
247+
});
226248
}
227249

228250
await t.commit();

0 commit comments

Comments
 (0)