-
Notifications
You must be signed in to change notification settings - Fork 299
fix: handle user.delete event [WPB-18869] #19440
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
| amplify.publish(WebAppEvents.LIFECYCLE.SIGN_OUT, SIGN_OUT_REASON.ACCOUNT_DELETED, true); | ||
| }, 100); | ||
| } | ||
| this.emit('userDeleted', qualified_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.
emit the event to be consumed by the conversation repo.
User deletion events are not part of the WebAppEvents amplify store the conversation repo could use
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #19440 +/- ##
==========================================
- Coverage 42.87% 42.86% -0.02%
==========================================
Files 1341 1341
Lines 32405 32422 +17
Branches 7174 7178 +4
==========================================
+ Hits 13895 13897 +2
- Misses 16843 16857 +14
- Partials 1667 1668 +1 🚀 New features to boost your workflow:
|
| * Event to delete the matching user. | ||
| */ | ||
| private userDelete({id}: {id: string}): void { | ||
| private userDelete({qualified_id}: {qualified_id: QualifiedId}): void { |
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.
qualified_id required for CONVERSATION_EVENT.MEMBER_LEAVE event used to display a message in a conversation
| private readonly onUserDeleted = async (userId: QualifiedId) => { | ||
| const found1to1Conversation = this.conversationState.get1to1ConversationWithUser(userId); | ||
| if (!found1to1Conversation) { | ||
| return; | ||
| } | ||
|
|
||
| const deletedEvent = EventBuilder.buildMemberDeleted( | ||
| found1to1Conversation, | ||
| userId, | ||
| this.serverTimeHandler.toServerTimestamp(), | ||
| ); | ||
| await this.eventRepository.injectEvent(deletedEvent, EventRepository.SOURCE.INJECTED); | ||
| }; |
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.
inject a CONVERSATION_EVENT.MEMBER_LEAVE event in 1:1 conversation with a deleted user
|
🔗 Download Full Report Artifact 🧪 Playwright Test Summary
Failed Tests:❌ Messages in Groups (tags: TC-8751, crit-flow-web)Location: specs/CriticalFlow/messagesInGroups-TC-8751.spec.ts:42 Errors: Flaky Tests: |
| get1to1ConversationWithUser(userId: QualifiedId): Conversation | undefined { | ||
| const foundMLSConversation = this.findMLS1to1Conversation(userId); | ||
| if (foundMLSConversation) { | ||
| return foundMLSConversation; | ||
| } | ||
| const foundProteusConversations = this.findProteus1to1Conversations(userId); | ||
| if (foundProteusConversations && foundProteusConversations.length > 0) { | ||
| return foundProteusConversations[0]; | ||
| } | ||
| return undefined; | ||
| } |
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.
this looks like it could be one find operation only?
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.
you mean something like this?
get1to1ConversationWithUser(userId: QualifiedId): Conversation | undefined {
return this.conversations().find(
conv => isMLS1to1ConversationWithUser(userId)(conv) || isProteus1to1ConversationWithUser(userId)(conv)
);
}We need to return the MLS conversation first I think
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.
yes. but the original code isn't that bad either. i'll leave it up to you.
| buildMemberDeleted( | ||
| conversationEntity: Conversation, | ||
| userId: QualifiedId, | ||
| currentTimestamp: number, | ||
| ): MemberLeaveEvent { | ||
| return { | ||
| ...buildQualifiedId(conversationEntity), | ||
| data: { | ||
| qualified_user_ids: [userId], | ||
| user_ids: [userId.id], | ||
| reason: MemberLeaveReason.USER_DELETED, | ||
| }, | ||
| from: userId.id, | ||
| time: conversationEntity.getNextIsoDate(currentTimestamp), | ||
| type: CONVERSATION_EVENT.MEMBER_LEAVE, | ||
| }; | ||
| }, | ||
|
|
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.
don't we have something for this already?
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.
yes, the buildMemberLeave builder, but it doesn't provide a MemberLeaveReason — in that case USER_DELETED
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.
can't we adjust it to provide the MemberLeaveReason?
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.
done here b7c8166
build user.delete event message inject memberleave event when a user is deleted add localisation string for user deleted event revert user event message changes revert user event message changes emit user.delete event
b7c8166 to
56255d1
Compare
|
* fix: handle user.delete event build user.delete event message inject memberleave event when a user is deleted add localisation string for user deleted event revert user event message changes revert user event message changes emit user.delete event * display user deleted message if other member leave messages are not valid * remove DE localization string * replace buildMemberDelete with existing buildMember leave builder
* fix: handle user.delete event [WPB-18869] (#19440) * fix: handle user.delete event build user.delete event message inject memberleave event when a user is deleted add localisation string for user deleted event revert user event message changes revert user event message changes emit user.delete event * display user deleted message if other member leave messages are not valid * remove DE localization string * replace buildMemberDelete with existing buildMember leave builder * runfix: extend UserDeleteEvent type * correct typo, add german localization



Description
user.deletebackend event are not being handled with 1:1 conversations with federated usersChecklist