Add account_warning notification
This commit is contained in:
parent
af86c09824
commit
e7492e0745
9 changed files with 70 additions and 3 deletions
|
@ -54,6 +54,7 @@ class Admin::AccountAction
|
|||
|
||||
process_email!
|
||||
process_queue!
|
||||
notify!
|
||||
end
|
||||
|
||||
def report
|
||||
|
@ -107,6 +108,10 @@ class Admin::AccountAction
|
|||
log_action(:create, @warning) if @warning.text.present? && type == 'none'
|
||||
end
|
||||
|
||||
def notify!
|
||||
LocalNotificationWorker.perform_async(target_account.id, @warning.id, 'AccountWarning', 'warning') if @warning && %w(none sensitive silence).include?(type)
|
||||
end
|
||||
|
||||
def process_reports!
|
||||
# If we're doing "mark as resolved" on a single report,
|
||||
# then we want to keep other reports open in case they
|
||||
|
|
|
@ -17,6 +17,7 @@ class Admin::StatusBatchAction
|
|||
|
||||
def save!
|
||||
process_action!
|
||||
notify!
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -157,6 +158,10 @@ class Admin::StatusBatchAction
|
|||
report.save!
|
||||
end
|
||||
|
||||
def notify!
|
||||
LocalNotificationWorker.perform_async(target_account.id, @warning.id, 'AccountWarning', 'warning') if warnable? && @warning
|
||||
end
|
||||
|
||||
def report
|
||||
@report ||= Report.find(report_id) if report_id.present?
|
||||
end
|
||||
|
|
|
@ -28,6 +28,7 @@ class Notification < ApplicationRecord
|
|||
'EmojiReaction' => :emoji_reaction,
|
||||
'StatusReference' => :status_reference,
|
||||
'Poll' => :poll,
|
||||
'AccountWarning' => :warning,
|
||||
}.freeze
|
||||
|
||||
TYPES = %i(
|
||||
|
@ -42,6 +43,7 @@ class Notification < ApplicationRecord
|
|||
reaction
|
||||
poll
|
||||
update
|
||||
warning
|
||||
admin.sign_up
|
||||
admin.report
|
||||
).freeze
|
||||
|
@ -73,6 +75,7 @@ class Notification < ApplicationRecord
|
|||
belongs_to :status_reference, inverse_of: :notification
|
||||
belongs_to :poll, inverse_of: false
|
||||
belongs_to :report, inverse_of: false
|
||||
belongs_to :account_warning, inverse_of: false
|
||||
end
|
||||
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
@ -159,6 +162,15 @@ class Notification < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def from_account_web
|
||||
case activity_type
|
||||
when 'AccountWarning'
|
||||
account_warning&.target_account
|
||||
else
|
||||
from_account
|
||||
end
|
||||
end
|
||||
|
||||
after_initialize :set_from_account
|
||||
before_validation :set_from_account
|
||||
|
||||
|
@ -168,7 +180,7 @@ class Notification < ApplicationRecord
|
|||
return unless new_record?
|
||||
|
||||
case activity_type
|
||||
when 'Status', 'Follow', 'Favourite', 'EmojiReaction', 'EmojiReact', 'FollowRequest', 'Poll', 'Report'
|
||||
when 'Status', 'Follow', 'Favourite', 'EmojiReaction', 'EmojiReact', 'FollowRequest', 'Poll', 'Report', 'AccountWarning'
|
||||
self.from_account_id = activity&.account_id
|
||||
when 'Mention', 'StatusReference'
|
||||
self.from_account_id = activity&.status&.account_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue