mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 06:13:43 +01:00
Delete statuses asynchronously but provide instant feedback in the API
This commit is contained in:
parent
5973ca3d11
commit
93a90cd9c3
2 changed files with 16 additions and 3 deletions
|
@ -58,7 +58,7 @@ class Api::V1::StatusesController < ApiController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@status = Status.where(account_id: current_user.account).find(params[:id])
|
@status = Status.where(account_id: current_user.account).find(params[:id])
|
||||||
RemoveStatusService.new.call(@status)
|
RemovalWorker.perform_async(@status.id)
|
||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,8 +68,12 @@ class Api::V1::StatusesController < ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
def unreblog
|
def unreblog
|
||||||
RemoveStatusService.new.call(Status.where(account_id: current_user.account, reblog_of_id: params[:id]).first!)
|
reblog = Status.where(account_id: current_user.account, reblog_of_id: params[:id]).first!
|
||||||
@status = Status.find(params[:id])
|
@status = reblog.reblog
|
||||||
|
@reblogged_map = { @status.id => false }
|
||||||
|
|
||||||
|
RemovalWorker.perform_async(reblog.id)
|
||||||
|
|
||||||
render action: :show
|
render action: :show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
9
app/workers/removal_worker.rb
Normal file
9
app/workers/removal_worker.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RemovalWorker
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
def perform(status_id)
|
||||||
|
RemoveStatusService.new.call(Status.find(status_id))
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue