mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 15:05:07 +00:00
Change email notifications to imply in-app notifications
This commit is contained in:
parent
b618241ce8
commit
e6f75114ef
|
@ -7,7 +7,7 @@ module Admin
|
|||
def new
|
||||
authorize @account, :show?
|
||||
|
||||
@account_action = Admin::AccountAction.new(type: params[:type], report_id: params[:report_id], send_email_notification: true, include_statuses: true)
|
||||
@account_action = Admin::AccountAction.new(type: params[:type], report_id: params[:report_id], send_email_notification: true, send_notification: true, include_statuses: true)
|
||||
@warning_presets = AccountWarningPreset.all
|
||||
end
|
||||
|
||||
|
@ -35,7 +35,7 @@ module Admin
|
|||
|
||||
def resource_params
|
||||
params
|
||||
.expect(admin_account_action: [:type, :report_id, :warning_preset_id, :text, :send_email_notification, :include_statuses])
|
||||
.expect(admin_account_action: [:type, :report_id, :warning_preset_id, :text, :send_email_notification, :send_notification, :include_statuses])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,8 +18,8 @@ class Admin::Reports::ActionsController < Admin::BaseController
|
|||
status_ids: @report.status_ids,
|
||||
current_account: current_account,
|
||||
report_id: @report.id,
|
||||
send_notification: !@report.spam?,
|
||||
send_email_notification: !@report.spam?,
|
||||
send_in_app_notification: !@report.spam?,
|
||||
text: params[:text]
|
||||
)
|
||||
|
||||
|
@ -30,8 +30,8 @@ class Admin::Reports::ActionsController < Admin::BaseController
|
|||
report_id: @report.id,
|
||||
target_account: @report.target_account,
|
||||
current_account: current_account,
|
||||
send_notification: !@report.spam?,
|
||||
send_email_notification: !@report.spam?,
|
||||
send_in_app_notification: !@report.spam?,
|
||||
text: params[:text]
|
||||
)
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Api::V1::Admin::AccountActionsController < Api::BaseController
|
|||
:warning_preset_id,
|
||||
:text,
|
||||
:send_email_notification,
|
||||
:send_in_app_notification
|
||||
:send_notification
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -285,6 +285,51 @@ async function mountReactComponent(element: Element) {
|
|||
);
|
||||
}
|
||||
|
||||
// In the account warning interface, email notifications imply in-app notifications, so update accordingly
|
||||
Rails.delegate(
|
||||
document,
|
||||
'#admin_account_action_send_email_notification',
|
||||
'change',
|
||||
() => {
|
||||
const sendNotificationElement = document.querySelector<HTMLInputElement>(
|
||||
'input#admin_account_action_send_notification',
|
||||
);
|
||||
|
||||
const sendEmailNotificationElement =
|
||||
document.querySelector<HTMLInputElement>(
|
||||
'input#admin_account_action_send_email_notification',
|
||||
);
|
||||
|
||||
if (sendNotificationElement && sendEmailNotificationElement?.checked) {
|
||||
sendNotificationElement.checked = true;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Rails.delegate(
|
||||
document,
|
||||
'#admin_account_action_send_notification',
|
||||
'change',
|
||||
() => {
|
||||
const sendNotificationElement = document.querySelector<HTMLInputElement>(
|
||||
'input#admin_account_action_send_notification',
|
||||
);
|
||||
|
||||
const sendEmailNotificationElement =
|
||||
document.querySelector<HTMLInputElement>(
|
||||
'input#admin_account_action_send_email_notification',
|
||||
);
|
||||
|
||||
if (
|
||||
sendNotificationElement &&
|
||||
sendEmailNotificationElement &&
|
||||
!sendNotificationElement.checked
|
||||
) {
|
||||
sendEmailNotificationElement.checked = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
ready(() => {
|
||||
const domainBlockSeveritySelect = document.querySelector<HTMLSelectElement>(
|
||||
'select#domain_block_severity',
|
||||
|
|
|
@ -20,18 +20,18 @@ class Admin::AccountAction
|
|||
:report_id,
|
||||
:warning_preset_id
|
||||
|
||||
attr_reader :warning, :send_email_notification, :send_in_app_notification, :include_statuses
|
||||
attr_reader :warning, :send_notification, :send_email_notification, :include_statuses
|
||||
|
||||
alias send_notification? send_notification
|
||||
alias send_email_notification? send_email_notification
|
||||
alias send_in_app_notification? send_in_app_notification
|
||||
alias include_statuses? include_statuses
|
||||
|
||||
validates :type, :target_account, :current_account, presence: true
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
||||
def initialize(attributes = {})
|
||||
@send_notification = true
|
||||
@send_email_notification = true
|
||||
@send_in_app_notification = true
|
||||
@include_statuses = true
|
||||
|
||||
super
|
||||
|
@ -41,8 +41,8 @@ class Admin::AccountAction
|
|||
@send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
||||
def send_in_app_notification=(value)
|
||||
@send_in_app_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
def send_notification=(value)
|
||||
@send_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
||||
def include_statuses=(value)
|
||||
|
@ -173,10 +173,14 @@ class Admin::AccountAction
|
|||
end
|
||||
|
||||
def process_notification!
|
||||
return unless target_account.local?
|
||||
return unless warnable?
|
||||
|
||||
UserMailer.warning(target_account.user, warning).deliver_later! if send_email_notification?
|
||||
LocalNotificationWorker.perform_async(target_account.id, warning.id, 'AccountWarning', 'moderation_warning') if send_in_app_notification?
|
||||
LocalNotificationWorker.perform_async(target_account.id, warning.id, 'AccountWarning', 'moderation_warning')
|
||||
end
|
||||
|
||||
def warnable?
|
||||
send_notification && target_account.local?
|
||||
end
|
||||
|
||||
def status_ids
|
||||
|
|
|
@ -9,14 +9,14 @@ class Admin::StatusBatchAction
|
|||
:status_ids, :report_id,
|
||||
:text
|
||||
|
||||
attr_reader :send_email_notification, :send_in_app_notification
|
||||
attr_reader :send_notification, :send_email_notification
|
||||
|
||||
def send_email_notification=(value)
|
||||
@send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
||||
def send_in_app_notification=(value)
|
||||
@send_in_app_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
def send_notification=(value)
|
||||
@send_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
||||
def save!
|
||||
|
@ -133,10 +133,14 @@ class Admin::StatusBatchAction
|
|||
end
|
||||
|
||||
def process_notification!
|
||||
return unless target_account.local?
|
||||
return unless warnable?
|
||||
|
||||
UserMailer.warning(target_account.user, @warning).deliver_later! if send_email_notification
|
||||
LocalNotificationWorker.perform_async(target_account.id, @warning.id, 'AccountWarning', 'moderation_warning') if send_in_app_notification
|
||||
LocalNotificationWorker.perform_async(target_account.id, @warning.id, 'AccountWarning', 'moderation_warning')
|
||||
end
|
||||
|
||||
def warnable?
|
||||
send_notification && target_account.local?
|
||||
end
|
||||
|
||||
def target_account
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
%hr.spacer/
|
||||
|
||||
.fields-group
|
||||
= f.input :send_email_notification,
|
||||
= f.input :send_notification,
|
||||
as: :boolean,
|
||||
wrapper: :with_label
|
||||
|
||||
= f.input :send_in_app_notification,
|
||||
.fields-group
|
||||
= f.input :send_email_notification,
|
||||
as: :boolean,
|
||||
wrapper: :with_label
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ en:
|
|||
admin_account_action:
|
||||
include_statuses: The user will see which posts have caused the moderation action or warning
|
||||
send_email_notification: The user will receive an email with an explanation of what happened with their account
|
||||
send_in_app_notification: The user will receive an in-app notification with an explanation of what happened with their account
|
||||
send_notification: The user will receive an in-app notification with an explanation of what happened with their account
|
||||
text_html: Optional. You can use post syntax. You can <a href="%{path}">add warning presets</a> to save time
|
||||
type_html: Choose what to do with <strong>%{acct}</strong>
|
||||
types:
|
||||
|
@ -174,8 +174,8 @@ en:
|
|||
title: Title
|
||||
admin_account_action:
|
||||
include_statuses: Include reported posts in the e-mail
|
||||
send_email_notification: Notify the user per e-mail
|
||||
send_in_app_notification: Notify the user in the application
|
||||
send_email_notification: Also notify the user per e-mail
|
||||
send_notification: Notify the user in the application
|
||||
text: Custom warning
|
||||
type: Action
|
||||
types:
|
||||
|
|
Loading…
Reference in New Issue
Block a user