From 46d51b9d405d461bd19fe0e3a228a7cb8e53388b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 29 Jun 2019 23:17:49 +0200 Subject: [PATCH] Add error when trying to follow OStatus accounts --- app/services/follow_service.rb | 2 +- app/services/unblock_service.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 373cf937cb909..8e118f5d34e23 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -13,7 +13,7 @@ def call(source_account, target_account, reblogs: nil) target_account = ResolveAccountService.new.call(target_account, skip_webfinger: true) raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended? - raise Mastodon::NotPermittedError if target_account.blocking?(source_account) || source_account.blocking?(target_account) || target_account.moved? + raise Mastodon::NotPermittedError if target_account.blocking?(source_account) || source_account.blocking?(target_account) || target_account.moved? || (!target_account.local? && target_account.ostatus?) if source_account.following?(target_account) # We're already following this account, but we'll call follow! again to diff --git a/app/services/unblock_service.rb b/app/services/unblock_service.rb index 4cc43dd77b6e3..c263ac8afe054 100644 --- a/app/services/unblock_service.rb +++ b/app/services/unblock_service.rb @@ -7,16 +7,14 @@ def call(account, target_account) return unless account.blocking?(target_account) unblock = account.unblock!(target_account) - create_notification(unblock) unless target_account.local? + create_notification(unblock) if !target_account.local? && target_account.activitypub? unblock end private def create_notification(unblock) - if unblock.target_account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(unblock), unblock.account_id, unblock.target_account.inbox_url) - end + ActivityPub::DeliveryWorker.perform_async(build_json(unblock), unblock.account_id, unblock.target_account.inbox_url) end def build_json(unblock)