Skip to content

Commit

Permalink
Fix race condition when reblogging a status (mastodon#25016)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Jun 21, 2023
1 parent f36a91f commit f9d785e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/api/v1/statuses/reblogs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class Api::V1::Statuses::ReblogsController < Api::BaseController
include Authorization
include Redisable
include Lockable

before_action -> { doorkeeper_authorize! :write, :'write:statuses' }
before_action :require_user!
Expand All @@ -10,7 +12,9 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
override_rate_limit_headers :create, family: :statuses

def create
@status = ReblogService.new.call(current_account, @reblog, reblog_params)
with_lock("reblog:#{current_account.id}:#{@reblog.id}") do
@status = ReblogService.new.call(current_account, @reblog, reblog_params)
end

render json: @status, serializer: REST::StatusSerializer
end
Expand Down

0 comments on commit f9d785e

Please sign in to comment.