Skip to content

Commit

Permalink
fixed invitation cache invalidation (#4966)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinyanakiev authored Feb 21, 2025
1 parent a46963c commit 259fc97
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/domain/access/role-set/role.set.resolver.mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,12 @@ export class RoleSetResolverMutations {

// Reload to trigger actions
invitation = await this.invitationService.getInvitationOrFail(
eventData.invitationID
eventData.invitationID,
{
relations: {
roleSet: true,
},
}
);
let invitationState = await this.invitationService.getLifecycleState(
invitation.id
Expand All @@ -949,20 +954,16 @@ export class RoleSetResolverMutations {
}

if (agentInfo.userID && invitation.roleSet) {
const isOpenInvitation =
await this.invitationService.isFinalizedInvitation(invitation.id);
invitationState = this.lifecycleService.getState(
invitation.lifecycle,
this.roleSetServiceLifecycleApplication.getApplicationMachine()
);
const isMember = invitationState === ApplicationLifecycleState.APPROVED;
if (agentInfo.userID && invitation.roleSet) {
if (!isOpenInvitation) {
await this.roleSetCacheService.deleteOpenInvitationFromCache(
agentInfo.userID,
invitation.roleSet.id
);
}
await this.roleSetCacheService.deleteOpenInvitationFromCache(
agentInfo.userID,
invitation.roleSet.id
);
await this.roleSetCacheService.setAgentIsMemberCache(
agentInfo.agentID,
invitation.roleSet.id,
Expand All @@ -971,18 +972,6 @@ export class RoleSetResolverMutations {
}
}

if (agentInfo.userID && invitation.roleSet) {
await this.roleSetCacheService.deleteOpenApplicationFromCache(
agentInfo.userID,
invitation.roleSet.id
);
await this.roleSetCacheService.setAgentIsMemberCache(
agentInfo.agentID,
invitation.roleSet.id,
true
);
}

return await this.invitationService.getInvitationOrFail(invitation.id);
}

Expand Down

0 comments on commit 259fc97

Please sign in to comment.