[replication] Try master if replica is missing status.
This commit is contained in:
parent
41790e4894
commit
588894e2c2
|
@ -34,6 +34,15 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
|
|||
end
|
||||
|
||||
def requested_status
|
||||
Status.find(params[:status_id])
|
||||
rs = nil
|
||||
begin
|
||||
rs = Status.find(params[:status_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Status.connection.stick_to_master!
|
||||
rs = Status.find(params[:status_id])
|
||||
end
|
||||
return rs unless rs.nil?
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -31,7 +31,15 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
|
|||
private
|
||||
|
||||
def status_for_reblog
|
||||
Status.find params[:status_id]
|
||||
rs = nil
|
||||
begin
|
||||
rs = Status.find(params[:status_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Status.connection.stick_to_master!
|
||||
rs = Status.find(params[:status_id])
|
||||
end
|
||||
return rs unless rs.nil?
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
def status_for_destroy
|
||||
|
|
|
@ -10,7 +10,14 @@ class FavouriteService < BaseService
|
|||
def call(account, status)
|
||||
authorize_with account, status, :favourite?
|
||||
|
||||
favourite = Favourite.find_by(account: account, status: status)
|
||||
favourite = nil
|
||||
begin
|
||||
favourite = Favourite.find_by(account: account, status: status)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Favourite.connection.stick_to_master!
|
||||
favourite = Favourite.find_by(account: account, status: status)
|
||||
end
|
||||
# favourite = Favourite.find_by(account: account, status: status)
|
||||
|
||||
return favourite unless favourite.nil?
|
||||
|
||||
|
|
|
@ -13,7 +13,14 @@ class ReblogService < BaseService
|
|||
|
||||
authorize_with account, reblogged_status, :reblog?
|
||||
|
||||
reblog = account.statuses.find_by(reblog: reblogged_status)
|
||||
reblog = nil
|
||||
begin
|
||||
reblog = account.statuses.find_by(reblog: reblogged_status)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
account.statuses.connection.stick_to_master!
|
||||
reblog = account.statuses.find_by(reblog: reblogged_status)
|
||||
end
|
||||
#reblog = account.statuses.find_by(reblog: reblogged_status)
|
||||
|
||||
return reblog unless reblog.nil?
|
||||
|
||||
|
|
Loading…
Reference in New Issue