Skip to content

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

Merged
merged 1 commit into from
Aug 1, 2025

Conversation

hentrymartin
Copy link
Collaborator

What's in this PR?

  • cancel invites on canceling the copilot opportunity

@@ -54,6 +56,14 @@ module.exports = [
}));
});

const allInvites = await models.ProjectMemberInvite.findAll({
Copy link

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),
Copy link

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({
Copy link

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();
Copy link

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(
Copy link

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.

@hentrymartin hentrymartin merged commit b9f8e59 into develop Aug 1, 2025
2 checks passed
@hentrymartin hentrymartin deleted the pm-1398 branch August 1, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant