Change notification request acceptance to immediately delete the request (#31256)
This commit is contained in:
parent
3e3450be36
commit
7996a9543d
4 changed files with 83 additions and 6 deletions
|
@ -3,8 +3,19 @@
|
|||
class UnfilterNotificationsWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(notification_request_id)
|
||||
@notification_request = NotificationRequest.find(notification_request_id)
|
||||
# Earlier versions of the feature passed a `notification_request` ID
|
||||
# If `to_account_id` is passed, the first argument is an account ID
|
||||
# TODO for after 4.3.0: drop the single-argument case
|
||||
def perform(notification_request_or_account_id, from_account_id = nil)
|
||||
if from_account_id.present?
|
||||
@notification_request = nil
|
||||
@from_account = Account.find(from_account_id)
|
||||
@recipient = Account.find(notification_request_or_account_id)
|
||||
else
|
||||
@notification_request = NotificationRequest.find(notification_request_or_account_id)
|
||||
@from_account = @notification_request.from_account
|
||||
@recipient = @notification_request.account
|
||||
end
|
||||
|
||||
push_to_conversations!
|
||||
unfilter_notifications!
|
||||
|
@ -16,7 +27,7 @@ class UnfilterNotificationsWorker
|
|||
private
|
||||
|
||||
def push_to_conversations!
|
||||
notifications_with_private_mentions.find_each { |notification| AccountConversation.add_status(@notification_request.account, notification.target_status) }
|
||||
notifications_with_private_mentions.reorder(nil).find_each(order: :desc) { |notification| AccountConversation.add_status(@recipient, notification.target_status) }
|
||||
end
|
||||
|
||||
def unfilter_notifications!
|
||||
|
@ -24,11 +35,11 @@ class UnfilterNotificationsWorker
|
|||
end
|
||||
|
||||
def remove_request!
|
||||
@notification_request.destroy!
|
||||
@notification_request&.destroy!
|
||||
end
|
||||
|
||||
def filtered_notifications
|
||||
Notification.where(account: @notification_request.account, from_account: @notification_request.from_account, filtered: true)
|
||||
Notification.where(account: @recipient, from_account: @from_account, filtered: true)
|
||||
end
|
||||
|
||||
def notifications_with_private_mentions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue