Skip to content
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

Re-adding a user/participant into a conversation creates a new participant object but can never be properly removed again #41

Open
wkeithchau opened this issue Apr 12, 2022 · 2 comments · May be fixed by #42

Comments

@wkeithchau
Copy link

The issue that I am experiencing is when trying to remove a user from a conversation for the second time.

When a user is re-added a new participant document is created and linked up with the conversation. Then when the same user is removed from the conversation for the second time conversation.removeParticipant isn't setting the deleted field on the correct participant document (it is actually setting it on the initial document that has already been flagged as deleted).

I could help fix this issue but how should this workflow be handled?

  1. Should conversation.addParticipant never create a new participant for the same user-conversation pairing and update the existing participant document?
  2. Or should conversation.removeParticipant be fixed so the query is finding the document that does not have the deleted flag set yet?
@StorytellerCZ
Copy link
Contributor

StorytellerCZ commented Apr 12, 2022

The second approach is better. Having the previously deleted records remain is good for audit log.

@wkeithchau wkeithchau linked a pull request Apr 13, 2022 that will close this issue
@wkeithchau
Copy link
Author

I've come across another spot that needs a similar fix to this issue.
There is a side-effect that is triggered from MessagesCollection.after.insert.

If a user has been re-added to a conversation and the other user creates a new message, they are removed from the conversations due to the MessagesCollection.after.insert. This hook updates the 'deleted' participant is with read set to false. This update then triggers the ParticipantsCollection.after.update hook to remove the participant from the conversation.

To fix this, the ParticipantsCollection.update query needs to target participants that are not marked as deleted. I can add this fix to #42.

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 a pull request may close this issue.

2 participants