forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add moderation warnings (mastodon#9519)
* Add moderation warnings Replace individual routes for disabling, silencing, and suspending a user, as well as the report update route, with a unified account action controller that allows you to select an action (none, disable, silence, suspend) as well as whether it should generate an e-mail notification with optional custom text. That notification, with the optional custom text, is saved as a warning. Additionally, there are warning presets you can configure to save time when performing the above. * Use Account#local_username_and_domain
- Loading branch information
1 parent
0fc2702
commit da24629
Showing
72 changed files
with
682 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class AccountActionsController < BaseController | ||
before_action :set_account | ||
|
||
def new | ||
@account_action = Admin::AccountAction.new(type: params[:type], report_id: params[:report_id], send_email_notification: true) | ||
@warning_presets = AccountWarningPreset.all | ||
end | ||
|
||
def create | ||
account_action = Admin::AccountAction.new(resource_params) | ||
account_action.target_account = @account | ||
account_action.current_account = current_account | ||
|
||
account_action.save! | ||
|
||
if account_action.with_report? | ||
redirect_to admin_report_path(account_action.report) | ||
else | ||
redirect_to admin_account_path(@account.id) | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_account | ||
@account = Account.find(params[:account_id]) | ||
end | ||
|
||
def resource_params | ||
params.require(:admin_account_action).permit(:type, :report_id, :warning_preset_id, :text, :send_email_notification) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class WarningPresetsController < BaseController | ||
before_action :set_warning_preset, except: [:index, :create] | ||
|
||
def index | ||
authorize :account_warning_preset, :index? | ||
|
||
@warning_presets = AccountWarningPreset.all | ||
@warning_preset = AccountWarningPreset.new | ||
end | ||
|
||
def create | ||
authorize :account_warning_preset, :create? | ||
|
||
@warning_preset = AccountWarningPreset.new(warning_preset_params) | ||
|
||
if @warning_preset.save | ||
redirect_to admin_warning_presets_path | ||
else | ||
@warning_presets = AccountWarningPreset.all | ||
render :index | ||
end | ||
end | ||
|
||
def edit | ||
authorize @warning_preset, :update? | ||
end | ||
|
||
def update | ||
authorize @warning_preset, :update? | ||
|
||
if @warning_preset.update(warning_preset_params) | ||
redirect_to admin_warning_presets_path | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
authorize @warning_preset, :destroy? | ||
|
||
@warning_preset.destroy! | ||
redirect_to admin_warning_presets_path | ||
end | ||
|
||
private | ||
|
||
def set_warning_preset | ||
@warning_preset = AccountWarningPreset.find(params[:id]) | ||
end | ||
|
||
def warning_preset_params | ||
params.require(:account_warning_preset).permit(:text) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.