From 4100f3dd63300a8dca40c5fe52d7687d8b0ee39a Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Mon, 9 Nov 2020 12:25:14 -0600 Subject: [PATCH] Removed unused ostatus, activitypub actions from service code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Removed: - unused ostatus, activitypub actions from service code --- app/models/form/account_batch.rb | 10 ------ ...after_block_domain_from_account_service.rb | 10 ------ app/services/authorize_follow_service.rb | 23 ------------ app/services/block_service.rb | 23 ------------ app/services/favourite_service.rb | 15 -------- app/services/follow_service.rb | 24 ------------- app/services/process_mentions_service.rb | 18 ---------- app/services/process_quote_service.rb | 11 ------ app/services/reblog_service.rb | 11 ------ app/services/reject_follow_service.rb | 23 ------------ app/services/suspend_account_service.rb | 12 ------- app/services/unblock_service.rb | 23 ------------ app/services/unfavourite_service.rb | 25 ------------- app/services/unfollow_service.rb | 36 ------------------- 14 files changed, 264 deletions(-) diff --git a/app/models/form/account_batch.rb b/app/models/form/account_batch.rb index 5bc44e80..1b48a763 100644 --- a/app/models/form/account_batch.rb +++ b/app/models/form/account_batch.rb @@ -51,16 +51,6 @@ class Form::AccountBatch def reject_follow!(follow) follow.destroy - - return unless follow.account.activitypub? - - json = ActiveModelSerializers::SerializableResource.new( - follow, - serializer: ActivityPub::RejectFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - - ActivityPub::DeliveryWorker.perform_async(json, current_account.id, follow.account.inbox_url) end def approve! diff --git a/app/services/after_block_domain_from_account_service.rb b/app/services/after_block_domain_from_account_service.rb index 180f1340..3a84bd44 100644 --- a/app/services/after_block_domain_from_account_service.rb +++ b/app/services/after_block_domain_from_account_service.rb @@ -28,15 +28,5 @@ class AfterBlockDomainFromAccountService < BaseService def reject_follow!(follow) follow.destroy - - return unless follow.account.activitypub? - - json = ActiveModelSerializers::SerializableResource.new( - follow, - serializer: ActivityPub::RejectFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - - ActivityPub::DeliveryWorker.perform_async(json, @account.id, follow.account.inbox_url) end end diff --git a/app/services/authorize_follow_service.rb b/app/services/authorize_follow_service.rb index f2e3ebe7..e504b70e 100644 --- a/app/services/authorize_follow_service.rb +++ b/app/services/authorize_follow_service.rb @@ -9,29 +9,6 @@ class AuthorizeFollowService < BaseService follow_request.authorize! end - create_notification(follow_request) unless source_account.local? follow_request end - - private - - def create_notification(follow_request) - if follow_request.account.ostatus? - NotificationWorker.perform_async(build_xml(follow_request), follow_request.target_account_id, follow_request.account_id) - elsif follow_request.account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(follow_request), follow_request.target_account_id, follow_request.account.inbox_url) - end - end - - def build_json(follow_request) - ActiveModelSerializers::SerializableResource.new( - follow_request, - serializer: ActivityPub::AcceptFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - end - - def build_xml(follow_request) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request)) - end end diff --git a/app/services/block_service.rb b/app/services/block_service.rb index 10ed470e..84aeabbb 100644 --- a/app/services/block_service.rb +++ b/app/services/block_service.rb @@ -11,29 +11,6 @@ class BlockService < BaseService block = account.block!(target_account) BlockWorker.perform_async(account.id, target_account.id) - create_notification(block) unless target_account.local? block end - - private - - def create_notification(block) - if block.target_account.ostatus? - NotificationWorker.perform_async(build_xml(block), block.account_id, block.target_account_id) - elsif block.target_account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(block), block.account_id, block.target_account.inbox_url) - end - end - - def build_json(block) - ActiveModelSerializers::SerializableResource.new( - block, - serializer: ActivityPub::BlockSerializer, - adapter: ActivityPub::Adapter - ).to_json - end - - def build_xml(block) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.block_salmon(block)) - end end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index b565bcc3..c9928150 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -29,10 +29,6 @@ class FavouriteService < BaseService if status.account.local? NotifyService.new.call(status.account, favourite) - elsif status.account.ostatus? - NotificationWorker.perform_async(build_xml(favourite), favourite.account_id, status.account_id) - elsif status.account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(favourite), favourite.account_id, status.account.inbox_url) end end @@ -42,15 +38,4 @@ class FavouriteService < BaseService PotentialFriendshipTracker.record(account.id, status.account_id, :favourite) end - def build_json(favourite) - Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new( - favourite, - serializer: ActivityPub::LikeSerializer, - adapter: ActivityPub::Adapter - ).as_json).sign!(favourite.account)) - end - - def build_xml(favourite) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.favourite_salmon(favourite)) - end end diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index b4e47722..ca9237e2 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -43,11 +43,6 @@ class FollowService < BaseService if target_account.local? LocalNotificationWorker.perform_async(target_account.id, follow_request.id, follow_request.class.name) - elsif target_account.ostatus? - NotificationWorker.perform_async(build_follow_request_xml(follow_request), source_account.id, target_account.id) - AfterRemoteFollowRequestWorker.perform_async(follow_request.id) - elsif target_account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(follow_request), source_account.id, target_account.inbox_url) end follow_request @@ -58,10 +53,6 @@ class FollowService < BaseService if target_account.local? LocalNotificationWorker.perform_async(target_account.id, follow.id, follow.class.name) - else - Pubsubhubbub::SubscribeWorker.perform_async(target_account.id) unless target_account.subscribed? - NotificationWorker.perform_async(build_follow_xml(follow), source_account.id, target_account.id) - AfterRemoteFollowWorker.perform_async(follow.id) end MergeWorker.perform_async(target_account.id, source_account.id) @@ -69,19 +60,4 @@ class FollowService < BaseService follow end - def build_follow_request_xml(follow_request) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_request_salmon(follow_request)) - end - - def build_follow_xml(follow) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_salmon(follow)) - end - - def build_json(follow_request) - ActiveModelSerializers::SerializableResource.new( - follow_request, - serializer: ActivityPub::FollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - end end diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index c1e86ae2..3c6d177f 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -48,27 +48,9 @@ class ProcessMentionsService < BaseService if mentioned_account.local? LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name) - elsif mentioned_account.ostatus? && !@status.stream_entry.hidden? - NotificationWorker.perform_async(ostatus_xml, @status.account_id, mentioned_account.id) - elsif mentioned_account.activitypub? - ActivityPub::DeliveryWorker.perform_async(activitypub_json, mention.status.account_id, mentioned_account.inbox_url) end end - def ostatus_xml - @ostatus_xml ||= stream_entry_to_xml(@status.stream_entry) - end - - def activitypub_json - return @activitypub_json if defined?(@activitypub_json) - payload = ActiveModelSerializers::SerializableResource.new( - @status, - serializer: ActivityPub::ActivitySerializer, - adapter: ActivityPub::Adapter - ).as_json - @activitypub_json = Oj.dump(@status.distributable? ? ActivityPub::LinkedDataSignature.new(payload).sign!(@status.account) : payload) - end - def resolve_account_service ResolveAccountService.new end diff --git a/app/services/process_quote_service.rb b/app/services/process_quote_service.rb index b532ae38..aa2d344f 100644 --- a/app/services/process_quote_service.rb +++ b/app/services/process_quote_service.rb @@ -18,10 +18,6 @@ class ProcessQuoteService < BaseService if quoted_status.account.local? LocalNotificationWorker.perform_async(quoted_status.account_id, status.id, status.class.name) - elsif quoted_status.account.ostatus? - NotificationWorker.perform_async(stream_entry_to_xml(status.stream_entry), status.account_id, quoted_status.account_id) - elsif quoted_status.account.activitypub? && !quoted_status.account.following?(status.account) - ActivityPub::DeliveryWorker.perform_async(build_json(status), status.account_id, quoted_status.account.inbox_url) end end @@ -31,12 +27,5 @@ class ProcessQuoteService < BaseService PotentialFriendshipTracker.record(status.account_id, status.quote.account_id, :reblog) end - def build_json(status) - Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new( - status, - serializer: ActivityPub::ActivitySerializer, - adapter: ActivityPub::Adapter - ).as_json).sign!(status.account)) - end end \ No newline at end of file diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 0c1ef526..9909a888 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -40,10 +40,6 @@ class ReblogService < BaseService if reblogged_status.account.local? LocalNotificationWorker.perform_async(reblogged_status.account_id, reblog.id, reblog.class.name) - elsif reblogged_status.account.ostatus? - NotificationWorker.perform_async(stream_entry_to_xml(reblog.stream_entry), reblog.account_id, reblogged_status.account_id) - elsif reblogged_status.account.activitypub? && !reblogged_status.account.following?(reblog.account) - ActivityPub::DeliveryWorker.perform_async(build_json(reblog), reblog.account_id, reblogged_status.account.inbox_url) end end @@ -53,11 +49,4 @@ class ReblogService < BaseService PotentialFriendshipTracker.record(account.id, reblog.reblog.account_id, :reblog) end - def build_json(reblog) - Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new( - reblog, - serializer: ActivityPub::ActivitySerializer, - adapter: ActivityPub::Adapter - ).as_json).sign!(reblog.account)) - end end diff --git a/app/services/reject_follow_service.rb b/app/services/reject_follow_service.rb index a91266aa..fe94801f 100644 --- a/app/services/reject_follow_service.rb +++ b/app/services/reject_follow_service.rb @@ -4,29 +4,6 @@ class RejectFollowService < BaseService def call(source_account, target_account) follow_request = FollowRequest.find_by!(account: source_account, target_account: target_account) follow_request.reject! - create_notification(follow_request) unless source_account.local? follow_request end - - private - - def create_notification(follow_request) - if follow_request.account.ostatus? - NotificationWorker.perform_async(build_xml(follow_request), follow_request.target_account_id, follow_request.account_id) - elsif follow_request.account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(follow_request), follow_request.target_account_id, follow_request.account.inbox_url) - end - end - - def build_json(follow_request) - ActiveModelSerializers::SerializableResource.new( - follow_request, - serializer: ActivityPub::RejectFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - end - - def build_xml(follow_request) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request)) - end end diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb index 411b8595..eee089d6 100644 --- a/app/services/suspend_account_service.rb +++ b/app/services/suspend_account_service.rb @@ -69,8 +69,6 @@ class SuspendAccountService < BaseService end def purge_content! - distribute_delete_actor! if @account.local? && !@options[:skip_distribution] - @account.statuses.reorder(nil).find_in_batches do |statuses| BatchedRemoveStatusService.new.call(statuses, skip_side_effects: @options[:destroy]) end @@ -108,16 +106,6 @@ class SuspendAccountService < BaseService association.in_batches.destroy_all end - def distribute_delete_actor! - # ActivityPub::DeliveryWorker.push_bulk(delivery_inboxes) do |inbox_url| - # [delete_actor_json, @account.id, inbox_url] - # end - - # ActivityPub::LowPriorityDeliveryWorker.push_bulk(low_priority_delivery_inboxes) do |inbox_url| - # [delete_actor_json, @account.id, inbox_url] - # end - end - def delete_actor_json return @delete_actor_json if defined?(@delete_actor_json) diff --git a/app/services/unblock_service.rb b/app/services/unblock_service.rb index 72fc5ab1..d901f1b5 100644 --- a/app/services/unblock_service.rb +++ b/app/services/unblock_service.rb @@ -5,29 +5,6 @@ class UnblockService < BaseService return unless account.blocking?(target_account) unblock = account.unblock!(target_account) - create_notification(unblock) unless target_account.local? unblock end - - private - - def create_notification(unblock) - if unblock.target_account.ostatus? - NotificationWorker.perform_async(build_xml(unblock), unblock.account_id, unblock.target_account_id) - elsif unblock.target_account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(unblock), unblock.account_id, unblock.target_account.inbox_url) - end - end - - def build_json(unblock) - ActiveModelSerializers::SerializableResource.new( - unblock, - serializer: ActivityPub::UndoBlockSerializer, - adapter: ActivityPub::Adapter - ).to_json - end - - def build_xml(block) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unblock_salmon(block)) - end end diff --git a/app/services/unfavourite_service.rb b/app/services/unfavourite_service.rb index 2fda11bd..2b4e2c27 100644 --- a/app/services/unfavourite_service.rb +++ b/app/services/unfavourite_service.rb @@ -4,31 +4,6 @@ class UnfavouriteService < BaseService def call(account, status) favourite = Favourite.find_by!(account: account, status: status) favourite.destroy! - create_notification(favourite) unless status.local? favourite end - - private - - def create_notification(favourite) - status = favourite.status - - if status.account.ostatus? - NotificationWorker.perform_async(build_xml(favourite), favourite.account_id, status.account_id) - elsif status.account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(favourite), favourite.account_id, status.account.inbox_url) - end - end - - def build_json(favourite) - Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new( - favourite, - serializer: ActivityPub::UndoLikeSerializer, - adapter: ActivityPub::Adapter - ).as_json).sign!(favourite.account)) - end - - def build_xml(favourite) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfavourite_salmon(favourite)) - end end diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb index 95da2a66..e4a6d0a4 100644 --- a/app/services/unfollow_service.rb +++ b/app/services/unfollow_service.rb @@ -19,8 +19,6 @@ class UnfollowService < BaseService return unless follow follow.destroy! - create_notification(follow) unless @target_account.local? - create_reject_notification(follow) if @target_account.local? && !@source_account.local? UnmergeWorker.perform_async(@target_account.id, @source_account.id) follow end @@ -31,41 +29,7 @@ class UnfollowService < BaseService return unless follow_request follow_request.destroy! - create_notification(follow_request) unless @target_account.local? follow_request end - def create_notification(follow) - if follow.target_account.ostatus? - NotificationWorker.perform_async(build_xml(follow), follow.account_id, follow.target_account_id) - elsif follow.target_account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_json(follow), follow.account_id, follow.target_account.inbox_url) - end - end - - def create_reject_notification(follow) - # Rejecting an already-existing follow request - return unless follow.account.activitypub? - ActivityPub::DeliveryWorker.perform_async(build_reject_json(follow), follow.target_account_id, follow.account.inbox_url) - end - - def build_json(follow) - ActiveModelSerializers::SerializableResource.new( - follow, - serializer: ActivityPub::UndoFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - end - - def build_reject_json(follow) - ActiveModelSerializers::SerializableResource.new( - follow, - serializer: ActivityPub::RejectFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - end - - def build_xml(follow) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfollow_salmon(follow)) - end end