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

[FIX] Subscriptions not removed when removing user #9432

Merged
merged 1 commit into from
Jan 17, 2018

Conversation

rodrigok
Copy link
Member

Bypass the cache and find the subscriptions directly from database to prevent the in memory changes while deleting.

The for each of the array in memory does not works cuz the array is changing the size.

@RocketChat/core

Closes #6535

Bypass the cache and find the subscriptions directly from database to prevent the in memory changes while deleting.

The for each of the array in memory does not works cuz the array is changing the size.
@mrsimpson
Copy link
Collaborator

@rodrigok what do you think about a migration which removes inconsistent subscriptions? While the fix prevents new issues, the obsolete subscriptions are aasige problem in existing installations.

@rodrigok
Copy link
Member Author

@mrsimpson Sure, but I don't think it should be a migration, I'll see how we could create and admin option to run the consistency fix, so I'll merge this now.

Thanks

@rodrigok rodrigok merged commit b62fcdb into develop Jan 17, 2018
@rodrigok rodrigok deleted the hotfix/delete-user branch January 17, 2018 17:03
@metalcated
Copy link

Once this is pushed into stable builds will this fix the existing problems for people affected by this bug?

@geekgonecrazy
Copy link
Contributor

This will only keep the problem from effecting new cases, does not fix the ones that have already had this happen

@Dirk23
Copy link

Dirk23 commented Mar 9, 2018

@geekgonecrazy Hi. It seems I have that problem with some users. Is there a fix for existing cases?

@geekgonecrazy
Copy link
Contributor

geekgonecrazy commented Mar 29, 2018

you could likely write a mongo query to do something like:

nouser = []
db.rocketchat_subscription.find({t:'d'}).forEach(function(subscription) {
  if (!db.users.findOne({_id: subscription.u._id})) {
    nouser.push(subscription);
  }
})

Then from there you could loop over nouser and delete the subscriptions that don't have a user

if your problem is instead that you have subscriptions hanging around in your channel list for users that are no more... you could use same loop. Instead take subscription.rid and look for rooms that exist for it. If no room exists for that subscription you could delete.

@Dirk23
Copy link

Dirk23 commented Apr 3, 2018

@geekgonecrazy thank you for your reply, but this query finds 0 entrys. Maybe my problem is different to the one in this thread?
I have users wich cant Direct Message each other. User2 tries to DM User1 but RocketChat Displays: No User with the name "User1" found. User3 can DM User1 without any Problem. User1 can DM to User2 and User2 gets a PushMessage, but cant display that message in RocketChat, because User2 sees the Errormessage

@geekgonecrazy
Copy link
Contributor

Did user1 at any point delete their user and then create an account with the exact same username?

@Dirk23
Copy link

Dirk23 commented Apr 5, 2018

Yes. the User was deleted and recreated once iirc.

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.

Deleting a user doesn't delete rocketchat_subscription's for DM's
6 participants