2017-01-24 12:40:41 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AfterBlockService < BaseService
|
|
|
|
def call(account, target_account)
|
2019-07-24 19:17:35 -07:00
|
|
|
@account = account
|
|
|
|
@target_account = target_account
|
|
|
|
|
|
|
|
clear_home_feed!
|
2021-05-10 08:31:55 -07:00
|
|
|
clear_list_feeds!
|
2024-08-06 03:07:16 -07:00
|
|
|
clear_notification_requests!
|
2019-07-24 19:17:35 -07:00
|
|
|
clear_notifications!
|
|
|
|
clear_conversations!
|
2017-01-24 12:40:41 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-07-24 19:17:35 -07:00
|
|
|
def clear_home_feed!
|
2020-09-07 18:41:16 -07:00
|
|
|
FeedManager.instance.clear_from_home(@account, @target_account)
|
2018-10-07 14:44:58 -07:00
|
|
|
end
|
|
|
|
|
2021-05-10 08:31:55 -07:00
|
|
|
def clear_list_feeds!
|
|
|
|
FeedManager.instance.clear_from_lists(@account, @target_account)
|
|
|
|
end
|
|
|
|
|
2019-07-24 19:17:35 -07:00
|
|
|
def clear_conversations!
|
|
|
|
AccountConversation.where(account: @account).where('? = ANY(participant_account_ids)', @target_account.id).in_batches.destroy_all
|
2018-10-07 14:44:58 -07:00
|
|
|
end
|
|
|
|
|
2019-07-24 19:17:35 -07:00
|
|
|
def clear_notifications!
|
|
|
|
Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all
|
2017-01-24 12:40:41 -08:00
|
|
|
end
|
2024-08-06 03:07:16 -07:00
|
|
|
|
|
|
|
def clear_notification_requests!
|
|
|
|
NotificationRequest.where(account: @account, from_account: @target_account).destroy_all
|
|
|
|
end
|
2017-01-24 12:40:41 -08:00
|
|
|
end
|