mirror of
https://github.com/yingziwu/mastodon.git
synced 2026-02-04 03:25:14 +00:00
Fix potential duplicate handling of quote accept/reject/delete (#37537)
This commit is contained in:
parent
ba0609bbaf
commit
6698901d57
3 changed files with 4 additions and 4 deletions
|
|
@ -46,7 +46,7 @@ class ActivityPub::Activity::Accept < ActivityPub::Activity
|
||||||
|
|
||||||
def accept_quote!(quote)
|
def accept_quote!(quote)
|
||||||
approval_uri = value_or_id(first_of_value(@json['result']))
|
approval_uri = value_or_id(first_of_value(@json['result']))
|
||||||
return if unsupported_uri_scheme?(approval_uri) || quote.quoted_account != @account || !quote.status.local?
|
return if unsupported_uri_scheme?(approval_uri) || quote.quoted_account != @account || !quote.status.local? || !quote.pending?
|
||||||
|
|
||||||
# NOTE: we are not going through `ActivityPub::VerifyQuoteService` as the `Accept` is as authoritative
|
# NOTE: we are not going through `ActivityPub::VerifyQuoteService` as the `Accept` is as authoritative
|
||||||
# as the stamp, but this means we are not checking the stamp, which may lead to inconsistencies
|
# as the stamp, but this means we are not checking the stamp, which may lead to inconsistencies
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def revoke_quote
|
def revoke_quote
|
||||||
@quote = Quote.find_by(approval_uri: object_uri, quoted_account: @account)
|
@quote = Quote.find_by(approval_uri: object_uri, quoted_account: @account, state: [:pending, :accepted])
|
||||||
return if @quote.nil?
|
return if @quote.nil?
|
||||||
|
|
||||||
ActivityPub::Forwarder.new(@account, @json, @quote.status).forward! if @quote.status.present?
|
ActivityPub::Forwarder.new(@account, @json, @quote.status).forward! if @quote.status.present?
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,9 @@ class Quote < ApplicationRecord
|
||||||
|
|
||||||
def reject!
|
def reject!
|
||||||
if accepted?
|
if accepted?
|
||||||
update!(state: :revoked)
|
update!(state: :revoked, approval_uri: nil)
|
||||||
elsif !revoked?
|
elsif !revoked?
|
||||||
update!(state: :rejected)
|
update!(state: :rejected, approval_uri: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue