mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-28 02:20:47 +00:00
Explicitly record Tombstone quotes as deleted
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
This adds a `deleted` state to the internal representation, but this does not change the API, which already included such a state.
This commit is contained in:
parent
a186bad399
commit
d7d6407d41
|
|
@ -220,8 +220,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
return unless @status_parser.quote?
|
return unless @status_parser.quote?
|
||||||
|
|
||||||
approval_uri = @status_parser.quote_approval_uri
|
approval_uri = @status_parser.quote_approval_uri
|
||||||
approval_uri = nil if unsupported_uri_scheme?(approval_uri)
|
approval_uri = nil if unsupported_uri_scheme?(approval_uri) || TagManager.instance.local_url?(approval_uri)
|
||||||
@quote = Quote.new(account: @account, approval_uri: approval_uri, legacy: @status_parser.legacy_quote?)
|
@quote = Quote.new(account: @account, approval_uri: approval_uri, legacy: @status_parser.legacy_quote?, state: @status_parser.deleted_quote? ? :deleted : :pending)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_hashtag(tag)
|
def process_hashtag(tag)
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,10 @@ class ActivityPub::Parser::StatusParser
|
||||||
%w(quote _misskey_quote quoteUrl quoteUri).any? { |key| @object[key].present? }
|
%w(quote _misskey_quote quoteUrl quoteUri).any? { |key| @object[key].present? }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deleted_quote?
|
||||||
|
@object['quote'].is_a?(Hash) && @object['quote']['type'] == 'Tombstone'
|
||||||
|
end
|
||||||
|
|
||||||
def quote_uri
|
def quote_uri
|
||||||
%w(quote _misskey_quote quoteUrl quoteUri).filter_map do |key|
|
%w(quote _misskey_quote quoteUrl quoteUri).filter_map do |key|
|
||||||
value_or_id(as_array(@object[key]).first)
|
value_or_id(as_array(@object[key]).first)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class Quote < ApplicationRecord
|
||||||
REFRESH_DEADLINE = 6.hours
|
REFRESH_DEADLINE = 6.hours
|
||||||
|
|
||||||
enum :state,
|
enum :state,
|
||||||
{ pending: 0, accepted: 1, rejected: 2, revoked: 3 },
|
{ pending: 0, accepted: 1, rejected: 2, revoked: 3, deleted: 4 },
|
||||||
validate: true
|
validate: true
|
||||||
|
|
||||||
belongs_to :status
|
belongs_to :status
|
||||||
|
|
|
||||||
|
|
@ -305,10 +305,12 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
approval_uri = nil if unsupported_uri_scheme?(approval_uri)
|
approval_uri = nil if unsupported_uri_scheme?(approval_uri)
|
||||||
|
|
||||||
if @status.quote.present?
|
if @status.quote.present?
|
||||||
|
state = @status_parser.deleted_quote? ? :deleted : :pending
|
||||||
|
|
||||||
# If the quoted post has changed, discard the old object and create a new one
|
# If the quoted post has changed, discard the old object and create a new one
|
||||||
if @status.quote.quoted_status.present? && ActivityPub::TagManager.instance.uri_for(@status.quote.quoted_status) != quote_uri
|
if @status.quote.quoted_status.present? && ActivityPub::TagManager.instance.uri_for(@status.quote.quoted_status) != quote_uri
|
||||||
@status.quote.destroy
|
@status.quote.destroy
|
||||||
quote = Quote.create(status: @status, approval_uri: approval_uri, legacy: @status_parser.legacy_quote?)
|
quote = Quote.create(status: @status, approval_uri: approval_uri, legacy: @status_parser.legacy_quote?, state: state)
|
||||||
@quote_changed = true
|
@quote_changed = true
|
||||||
else
|
else
|
||||||
quote = @status.quote
|
quote = @status.quote
|
||||||
|
|
|
||||||
|
|
@ -956,7 +956,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.quote).to_not be_nil
|
expect(status.quote).to_not be_nil
|
||||||
expect(status.quote).to have_attributes(
|
expect(status.quote).to have_attributes(
|
||||||
state: 'pending',
|
state: 'deleted',
|
||||||
approval_uri: nil
|
approval_uri: nil
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1008,7 +1008,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||||
it 'updates the URI and unverifies the quote' do
|
it 'updates the URI and unverifies the quote' do
|
||||||
expect { subject.call(status, json, json) }
|
expect { subject.call(status, json, json) }
|
||||||
.to change { status.quote.quoted_status }.from(quoted_status).to(nil)
|
.to change { status.quote.quoted_status }.from(quoted_status).to(nil)
|
||||||
.and change { status.quote.state }.from('accepted')
|
.and change { status.quote.state }.from('accepted').to('deleted')
|
||||||
|
|
||||||
expect { quote.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { quote.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user