Add in-app notifications for moderation actions/warnings (#30065)
This commit is contained in:
parent
0ec061aa8f
commit
4ef0b48b95
13 changed files with 188 additions and 21 deletions
|
@ -52,7 +52,7 @@ class Admin::AccountAction
|
|||
process_reports!
|
||||
end
|
||||
|
||||
process_email!
|
||||
process_notification!
|
||||
process_queue!
|
||||
end
|
||||
|
||||
|
@ -158,8 +158,11 @@ class Admin::AccountAction
|
|||
queue_suspension_worker! if type == 'suspend'
|
||||
end
|
||||
|
||||
def process_email!
|
||||
UserMailer.warning(target_account.user, warning).deliver_later! if warnable?
|
||||
def process_notification!
|
||||
return unless warnable?
|
||||
|
||||
UserMailer.warning(target_account.user, warning).deliver_later!
|
||||
LocalNotificationWorker.perform_async(target_account.id, warning.id, 'AccountWarning', 'moderation_warning')
|
||||
end
|
||||
|
||||
def warnable?
|
||||
|
|
|
@ -65,7 +65,8 @@ class Admin::StatusBatchAction
|
|||
statuses.each { |status| Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true) } unless target_account.local?
|
||||
end
|
||||
|
||||
UserMailer.warning(target_account.user, @warning).deliver_later! if warnable?
|
||||
process_notification!
|
||||
|
||||
RemovalWorker.push_bulk(status_ids) { |status_id| [status_id, { 'preserve' => target_account.local?, 'immediate' => !target_account.local? }] }
|
||||
end
|
||||
|
||||
|
@ -101,7 +102,7 @@ class Admin::StatusBatchAction
|
|||
text: text
|
||||
)
|
||||
|
||||
UserMailer.warning(target_account.user, @warning).deliver_later! if warnable?
|
||||
process_notification!
|
||||
end
|
||||
|
||||
def handle_report!
|
||||
|
@ -127,6 +128,13 @@ class Admin::StatusBatchAction
|
|||
!report.nil?
|
||||
end
|
||||
|
||||
def process_notification!
|
||||
return unless warnable?
|
||||
|
||||
UserMailer.warning(target_account.user, @warning).deliver_later!
|
||||
LocalNotificationWorker.perform_async(target_account.id, @warning.id, 'AccountWarning', 'moderation_warning')
|
||||
end
|
||||
|
||||
def warnable?
|
||||
send_email_notification && target_account.local?
|
||||
end
|
||||
|
|
|
@ -57,6 +57,9 @@ class Notification < ApplicationRecord
|
|||
severed_relationships: {
|
||||
filterable: false,
|
||||
}.freeze,
|
||||
moderation_warning: {
|
||||
filterable: false,
|
||||
}.freeze,
|
||||
'admin.sign_up': {
|
||||
filterable: false,
|
||||
}.freeze,
|
||||
|
@ -90,6 +93,7 @@ class Notification < ApplicationRecord
|
|||
belongs_to :poll, inverse_of: false
|
||||
belongs_to :report, inverse_of: false
|
||||
belongs_to :account_relationship_severance_event, inverse_of: false
|
||||
belongs_to :account_warning, inverse_of: false
|
||||
end
|
||||
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
@ -180,7 +184,7 @@ class Notification < ApplicationRecord
|
|||
return unless new_record?
|
||||
|
||||
case activity_type
|
||||
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report'
|
||||
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report', 'AccountWarning'
|
||||
self.from_account_id = activity&.account_id
|
||||
when 'Mention'
|
||||
self.from_account_id = activity&.status&.account_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue