From 7fe2993b878339c277d9156f994c7e8ec21dd2ee Mon Sep 17 00:00:00 2001 From: Wiktor Date: Mon, 14 May 2018 22:56:45 +0200 Subject: Fix account URI when updating ActivityPub account (#7488) Updates account `uri` field on each call to `update_account` instead of only once during `create_account` to mirror the same behavior in OStatus `ResolveAccountService` class [0]. ActivityPub accounts are identified using `@username` and `@domain` pair instead of URI since #6842. This fixes #7479: a bug when the account identified by `@username` and `@domain` changes its URI. [0]: https://github.com/tootsuite/mastodon/blob/03b69ebc450efc07246bd64204276941b7ede3fc/app/services/resolve_account_service.rb#L121 --- app/services/activitypub/process_account_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/services/activitypub/process_account_service.rb') diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 721c9c928..783bbd8e5 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -44,7 +44,6 @@ class ActivityPub::ProcessAccountService < BaseService @account.protocol = :activitypub @account.username = @username @account.domain = @domain - @account.uri = @uri @account.suspended = true if auto_suspend? @account.silenced = true if auto_silence? @account.private_key = nil @@ -67,6 +66,7 @@ class ActivityPub::ProcessAccountService < BaseService @account.followers_url = @json['followers'] || '' @account.featured_collection_url = @json['featured'] || '' @account.url = url || @uri + @account.uri = @uri @account.display_name = @json['name'] || '' @account.note = @json['summary'] || '' @account.locked = @json['manuallyApprovesFollowers'] || false -- cgit From 55fd55714a374eaedfab457f7e7254f816911ff1 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Wed, 16 May 2018 19:29:45 +0900 Subject: Raise Mastodon::RaceConditionError if Redis lock failed (#7511) An explicit error allows user agents to know the error and Sidekiq to retry. --- app/controllers/media_proxy_controller.rb | 2 ++ app/lib/activitypub/activity/create.rb | 2 ++ app/lib/ostatus/activity/creation.rb | 2 ++ app/services/activitypub/process_account_service.rb | 2 ++ app/services/fetch_link_card_service.rb | 2 ++ app/services/resolve_account_service.rb | 2 ++ 6 files changed, 12 insertions(+) (limited to 'app/services/activitypub/process_account_service.rb') diff --git a/app/controllers/media_proxy_controller.rb b/app/controllers/media_proxy_controller.rb index 155670837..d820b257e 100644 --- a/app/controllers/media_proxy_controller.rb +++ b/app/controllers/media_proxy_controller.rb @@ -8,6 +8,8 @@ class MediaProxyController < ApplicationController if lock.acquired? @media_attachment = MediaAttachment.remote.find(params[:id]) redownload! if @media_attachment.needs_redownload? && !reject_media? + else + raise Mastodon::RaceConditionError end end diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 8d17a4ebe..ab1d63cd4 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -11,6 +11,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity if lock.acquired? @status = find_existing_status process_status if @status.nil? + else + raise Mastodon::RaceConditionError end end diff --git a/app/lib/ostatus/activity/creation.rb b/app/lib/ostatus/activity/creation.rb index dbccc8330..d3a303a0c 100644 --- a/app/lib/ostatus/activity/creation.rb +++ b/app/lib/ostatus/activity/creation.rb @@ -15,6 +15,8 @@ class OStatus::Activity::Creation < OStatus::Activity::Base @status = find_status(id) return [@status, false] unless @status.nil? @status = process_status + else + raise Mastodon::RaceConditionError end end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 783bbd8e5..453253db4 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -23,6 +23,8 @@ class ActivityPub::ProcessAccountService < BaseService create_account if @account.nil? update_account process_tags + else + raise Mastodon::RaceConditionError end end diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index f9b1b2f0c..86d0f9971 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -23,6 +23,8 @@ class FetchLinkCardService < BaseService if lock.acquired? @card = PreviewCard.find_by(url: @url) process_url if @card.nil? || @card.updated_at <= 2.weeks.ago + else + raise Mastodon::RaceConditionError end end diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb index de8d1151d..4323e7f06 100644 --- a/app/services/resolve_account_service.rb +++ b/app/services/resolve_account_service.rb @@ -49,6 +49,8 @@ class ResolveAccountService < BaseService else handle_ostatus end + else + raise Mastodon::RaceConditionError end end -- cgit