dont delete chat channel memberships multiple times (#6556)
This commit is contained in:
parent
8e4905522d
commit
5ec96613df
1 changed files with 2 additions and 10 deletions
|
|
@ -3,18 +3,10 @@ module Users
|
|||
def self.call(user)
|
||||
# We only destroy direct message channels, not open and invite-only ones
|
||||
direct_channels = user.chat_channels.where(channel_type: "direct")
|
||||
direct_channels.each do |direct_channel|
|
||||
cleanup_memberships(direct_channel.chat_channel_memberships)
|
||||
direct_channel.destroy!
|
||||
end
|
||||
direct_channels.each(&:destroy!)
|
||||
|
||||
# Clean up the banished user's remaining channel memberships
|
||||
cleanup_memberships(user.chat_channel_memberships)
|
||||
user.reload.chat_channel_memberships.each(&:destroy!)
|
||||
end
|
||||
|
||||
def self.cleanup_memberships(chat_channel_memberships)
|
||||
chat_channel_memberships.each(&:destroy!)
|
||||
end
|
||||
private_class_method :cleanup_memberships
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue