Remove destroy_empty_dm_channels callback (#7911)

This commit is contained in:
rhymes 2020-05-19 12:44:31 +02:00 committed by GitHub
parent 691efd1f7b
commit df4681a114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -167,7 +167,6 @@ class User < ApplicationRecord
before_validation :set_config_input
before_validation :downcase_email
before_validation :check_for_username_change
before_destroy :destroy_empty_dm_channels, prepend: true
before_destroy :destroy_follows, prepend: true
before_destroy :unsubscribe_from_newsletters, prepend: true
@ -598,15 +597,6 @@ class User < ApplicationRecord
score.to_i
end
def destroy_empty_dm_channels
return if chat_channels.empty? ||
chat_channels.where(channel_type: "direct").empty?
empty_dm_channels = chat_channels.where(channel_type: "direct").
select { |chat_channel| chat_channel.messages.empty? }
empty_dm_channels.destroy_all
end
def destroy_follows
follower_relationships = Follow.followable_user(id)
follower_relationships.destroy_all