[FIX] Delete removed user's subscriptions#10700
Merged
sampaiodiego merged 7 commits intodevelopfrom Aug 21, 2018
Merged
Conversation
…te past subscriptions
Member
|
@Hudell update the migration please |
ggazzo
reviewed
Jun 13, 2018
| @@ -19,12 +19,13 @@ RocketChat.deleteUser = function(userId) { | |||
| RocketChat.models.Subscriptions.db.findByUserId(userId).forEach((subscription) => { | |||
Member
There was a problem hiding this comment.
I think this code is wrong, we dont delete orphan subscriptions and we dont test if the user is the last owner/moderator and etc....
Member
There was a problem hiding this comment.
RocketChat.models.Subscriptions.db.findByUserId(userId).forEach(({rid}) => {
const room = RocketChat.models.Rooms.findOneById(rid);
RocketChat.models.Subscriptions.removeByRoomId(rid);
if (room) {
if (room.t === 'd') {
RocketChat.models.Messages.removeByRoomId(rid);
return RocketChat.models.Rooms.removeById(rid);
}
if (room.usernames && room.usernames.length === 1) {//should test owners and choose another user
RocketChat.models.Messages.removeByRoomId(rid);
RocketChat.models.Rooms.removeById(rid); // Remove non-channel rooms with only 1 user (the one being deleted)
}
}
});
ggazzo
requested changes
Jun 13, 2018
Member
ggazzo
left a comment
There was a problem hiding this comment.
check that situation (last owner)
Member
|
@Hudell can you update and fix the conflicts? |
rodrigok
requested changes
Aug 20, 2018
server/startup/migrations/v131.js
Outdated
| RocketChat.models.Subscriptions.removeByRoomId(subscription.rid); | ||
| RocketChat.models.Messages.removeByRoomId(subscription.rid); | ||
| RocketChat.models.Rooms.removeById(subscription.rid); | ||
| } else if (room.t !== 'c' && room.usernames.length === 1) { |
Member
There was a problem hiding this comment.
room.usernamesisn't valid anymore.- Don't we delete the messages?
rodrigok
previously approved these changes
Aug 20, 2018
rodrigok
approved these changes
Aug 20, 2018
Merged
|
This is still an Issue with 0.70.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref #6535
This PR adds a migration to delete the subscriptions and empty rooms of users who have been removed.
It also changes the user deletion script to remove DM rooms and subscriptions to empty private rooms, using the same logic from the migration.