Add admin status edit commands
This commit is contained in:
parent
7910ab0333
commit
ad102071bc
6 changed files with 92 additions and 3 deletions
|
@ -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,56 @@ 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
|
||||
)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def remove_media
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
media_ids: [],
|
||||
media_attributes: []
|
||||
)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def force_sensitive
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
sensitive: true
|
||||
)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def force_cw
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
spoiler_text: 'CW'
|
||||
)
|
||||
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 })
|
||||
redirect_to admin_account_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def admin_status_batch_action_params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue