Change dismissing a notification to clear existing filtered notifications for that account (#31329)
This commit is contained in:
parent
6f285bb2a6
commit
670e4655d1
5 changed files with 61 additions and 1 deletions
|
@ -29,7 +29,7 @@ class Api::V1::Notifications::RequestsController < Api::BaseController
|
|||
end
|
||||
|
||||
def dismiss
|
||||
@request.destroy!
|
||||
DismissNotificationRequestService.new.call(@request)
|
||||
render_empty
|
||||
end
|
||||
|
||||
|
|
8
app/services/dismiss_notification_request_service.rb
Normal file
8
app/services/dismiss_notification_request_service.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DismissNotificationRequestService < BaseService
|
||||
def call(request)
|
||||
FilteredNotificationCleanupWorker.perform_async(request.account_id, request.from_account_id)
|
||||
request.destroy!
|
||||
end
|
||||
end
|
9
app/workers/filtered_notification_cleanup_worker.rb
Normal file
9
app/workers/filtered_notification_cleanup_worker.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FilteredNotificationCleanupWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(account_id, from_account_id)
|
||||
Notification.where(account_id: account_id, from_account_id: from_account_id, filtered: true).reorder(nil).in_batches(order: :desc).delete_all
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue