Merge branch 'kb_development' into kb_migration

This commit is contained in:
KMY 2023-03-17 09:31:21 +09:00
commit d6008cffb5
19 changed files with 161 additions and 23 deletions

View file

@ -4,7 +4,7 @@ module Admin
class StatusesController < BaseController
before_action :set_account
before_action :set_statuses, except: :show
before_action :set_status, only: :show
before_action :set_status, only: [:show, :remove_history, :remove_media, :force_sensitive, :force_cw, :remove_status]
PER_PAGE = 20
@ -29,6 +29,61 @@ module Admin
redirect_to after_create_redirect_path
end
def remove_history
authorize [:admin, @status], :show?
UpdateStatusService.new.call(
@status,
@account.id,
no_history: true
)
log_action(:remove_history, @status)
redirect_to admin_account_status_path
end
def remove_media
authorize [:admin, @status], :show?
UpdateStatusService.new.call(
@status,
@account.id,
media_ids: [],
media_attributes: []
)
log_action(:remove_media, @status)
redirect_to admin_account_status_path
end
def force_sensitive
authorize [:admin, @status], :show?
UpdateStatusService.new.call(
@status,
@account.id,
sensitive: true
)
log_action(:force_sensitive, @status)
redirect_to admin_account_status_path
end
def force_cw
authorize [:admin, @status], :show?
UpdateStatusService.new.call(
@status,
@account.id,
spoiler_text: 'CW'
)
log_action(:force_cw, @status)
redirect_to admin_account_status_path
end
def remove_status
authorize [:admin, @status], :show?
@status.discard_with_reblogs
StatusPin.find_by(status: @status)&.destroy
@status.account.statuses_count = @status.account.statuses_count - 1
RemovalWorker.perform_async(@status.id, { 'redraft' => false })
log_action(:remove_status, @status)
redirect_to admin_account_path
end
private
def admin_status_batch_action_params

View file

@ -20,7 +20,7 @@ class Settings::ProfilesController < Settings::BaseController
private
def account_params
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :group_message_following_only, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
end
def set_account