mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-29 14:35:06 +01:00
Fix NameError
in status update processing (#33161)
This commit is contained in:
parent
13ab4b54e2
commit
23376cb691
@ -204,7 +204,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||||||
mention ||= account.mentions.new(status: @status)
|
mention ||= account.mentions.new(status: @status)
|
||||||
|
|
||||||
current_mentions << mention
|
current_mentions << mention
|
||||||
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS
|
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
|
||||||
# Since previous mentions are about already-known accounts,
|
# Since previous mentions are about already-known accounts,
|
||||||
# they don't try to resolve again and won't fall into this case.
|
# they don't try to resolve again and won't fall into this case.
|
||||||
# In other words, this failure case is only for new mentions and won't
|
# In other words, this failure case is only for new mentions and won't
|
||||||
|
@ -6,6 +6,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) }
|
let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) }
|
||||||
|
let(:bogus_mention) { 'https://example.com/users/erroringuser' }
|
||||||
let(:payload) do
|
let(:payload) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
@ -17,6 +18,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||||||
tag: [
|
tag: [
|
||||||
{ type: 'Hashtag', name: 'hoge' },
|
{ type: 'Hashtag', name: 'hoge' },
|
||||||
{ type: 'Mention', href: ActivityPub::TagManager.instance.uri_for(alice) },
|
{ type: 'Mention', href: ActivityPub::TagManager.instance.uri_for(alice) },
|
||||||
|
{ type: 'Mention', href: bogus_mention },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -33,16 +35,18 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||||||
mentions.each { |a| Fabricate(:mention, status: status, account: a) }
|
mentions.each { |a| Fabricate(:mention, status: status, account: a) }
|
||||||
tags.each { |t| status.tags << t }
|
tags.each { |t| status.tags << t }
|
||||||
media_attachments.each { |m| status.media_attachments << m }
|
media_attachments.each { |m| status.media_attachments << m }
|
||||||
|
stub_request(:get, bogus_mention).to_raise(HTTP::ConnectionError)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
it 'updates text and content warning' do
|
it 'updates text and content warning, and schedules re-fetching broken mention' do
|
||||||
subject.call(status, json, json)
|
subject.call(status, json, json)
|
||||||
expect(status.reload)
|
expect(status.reload)
|
||||||
.to have_attributes(
|
.to have_attributes(
|
||||||
text: eq('Hello universe'),
|
text: eq('Hello universe'),
|
||||||
spoiler_text: eq('Show more')
|
spoiler_text: eq('Show more')
|
||||||
)
|
)
|
||||||
|
expect(MentionResolveWorker).to have_enqueued_sidekiq_job(status.id, bogus_mention, anything)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the changes are only in sanitized-out HTML' do
|
context 'when the changes are only in sanitized-out HTML' do
|
||||||
|
Loading…
Reference in New Issue
Block a user