mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Merge f6bbd046e9
into a50c8e951f
This commit is contained in:
commit
9ea71c0757
2 changed files with 39 additions and 1 deletions
|
@ -225,7 +225,11 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
return if tag['href'].blank?
|
return if tag['href'].blank?
|
||||||
|
|
||||||
account = account_from_uri(tag['href'])
|
account = account_from_uri(tag['href'])
|
||||||
account = ActivityPub::FetchRemoteAccountService.new.call(tag['href'], request_id: @options[:request_id]) if account.nil?
|
begin
|
||||||
|
account = ActivityPub::FetchRemoteAccountService.new.call(tag['href'], request_id: @options[:request_id]) if account.nil?
|
||||||
|
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
|
||||||
|
account = nil
|
||||||
|
end
|
||||||
|
|
||||||
return if account.nil?
|
return if account.nil?
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,24 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:invalid_mention_json) do
|
||||||
|
{
|
||||||
|
id: [ActivityPub::TagManager.instance.uri_for(sender), 'post2'].join('/'),
|
||||||
|
type: 'Note',
|
||||||
|
to: [
|
||||||
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
ActivityPub::TagManager.instance.uri_for(follower),
|
||||||
|
],
|
||||||
|
content: '@bob lorem ipsum',
|
||||||
|
published: 1.hour.ago.utc.iso8601,
|
||||||
|
updated: 1.hour.ago.utc.iso8601,
|
||||||
|
tag: {
|
||||||
|
type: 'Mention',
|
||||||
|
href: 'http://notexisting.dontexistingtld/actor',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def activity_for_object(json)
|
def activity_for_object(json)
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
@ -117,6 +135,22 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
# Creates two notifications
|
# Creates two notifications
|
||||||
expect(Notification.count).to eq 2
|
expect(Notification.count).to eq 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'ignores unprocessable mention', :aggregate_failures do
|
||||||
|
stub_request(:get, invalid_mention_json[:tag][:href]).to_raise(HTTP::ConnectionError)
|
||||||
|
# When receiving the post that contains an invalid mention…
|
||||||
|
described_class.new(activity_for_object(invalid_mention_json), sender, delivery: true).perform
|
||||||
|
|
||||||
|
# NOTE: Refering explicitly to the workers is a bit awkward
|
||||||
|
DistributionWorker.drain
|
||||||
|
FeedInsertWorker.drain
|
||||||
|
|
||||||
|
# …it creates a status with an unknown parent
|
||||||
|
status = Status.find_by(uri: invalid_mention_json[:id])
|
||||||
|
|
||||||
|
# Check the process did not crash
|
||||||
|
expect(status.nil?).to be false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
|
|
Loading…
Reference in a new issue