-
Notifications
You must be signed in to change notification settings - Fork 55
fix(PM-1398): cancel invites on canceling the copilot opportunity #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -54,6 +56,14 @@ module.exports = [ | |||
})); | |||
}); | |||
|
|||
const allInvites = await models.ProjectMemberInvite.findAll({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the findAll
operation to ensure that any issues with retrieving invites do not cause the entire operation to fail.
const allInvites = await models.ProjectMemberInvite.findAll({ | ||
where: { | ||
applicationId: { | ||
[Op.in]: applications.map(item => item.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that applications.map(item => item.id)
returns a valid array of IDs. If applications
is empty or undefined, this could lead to unexpected behavior. Consider adding a check or default value.
// associated to the copilot opportunity | ||
// with cancel status | ||
for (const invite of allInvites) { | ||
await invite.update({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the invite.update
operation to ensure that any issues during the update process are caught and managed appropriately.
await invite.update({ | ||
status: INVITE_STATUS.CANCELED, | ||
}); | ||
await invite.reload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The invite.reload()
operation might not be necessary if the invite.update
operation already returns the updated instance. Consider checking if this step can be optimized or removed.
status: INVITE_STATUS.CANCELED, | ||
}); | ||
await invite.reload(); | ||
util.sendResourceToKafkaBus( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the util.sendResourceToKafkaBus
function to ensure that any issues with sending the message to the Kafka bus are caught and managed appropriately.
What's in this PR?