Removed unused ostatus, activitypub actions from service code
• Removed: - unused ostatus, activitypub actions from service code
This commit is contained in:
parent
bfd1e1ef9d
commit
4100f3dd63
@ -51,16 +51,6 @@ class Form::AccountBatch
|
|||||||
|
|
||||||
def reject_follow!(follow)
|
def reject_follow!(follow)
|
||||||
follow.destroy
|
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
|
end
|
||||||
|
|
||||||
def approve!
|
def approve!
|
||||||
|
@ -28,15 +28,5 @@ class AfterBlockDomainFromAccountService < BaseService
|
|||||||
|
|
||||||
def reject_follow!(follow)
|
def reject_follow!(follow)
|
||||||
follow.destroy
|
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
|
||||||
end
|
end
|
||||||
|
@ -9,29 +9,6 @@ class AuthorizeFollowService < BaseService
|
|||||||
follow_request.authorize!
|
follow_request.authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
create_notification(follow_request) unless source_account.local?
|
|
||||||
follow_request
|
follow_request
|
||||||
end
|
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
|
end
|
||||||
|
@ -11,29 +11,6 @@ class BlockService < BaseService
|
|||||||
block = account.block!(target_account)
|
block = account.block!(target_account)
|
||||||
|
|
||||||
BlockWorker.perform_async(account.id, target_account.id)
|
BlockWorker.perform_async(account.id, target_account.id)
|
||||||
create_notification(block) unless target_account.local?
|
|
||||||
block
|
block
|
||||||
end
|
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
|
end
|
||||||
|
@ -29,10 +29,6 @@ class FavouriteService < BaseService
|
|||||||
|
|
||||||
if status.account.local?
|
if status.account.local?
|
||||||
NotifyService.new.call(status.account, favourite)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,15 +38,4 @@ class FavouriteService < BaseService
|
|||||||
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
|
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
|
||||||
end
|
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
|
end
|
||||||
|
@ -43,11 +43,6 @@ class FollowService < BaseService
|
|||||||
|
|
||||||
if target_account.local?
|
if target_account.local?
|
||||||
LocalNotificationWorker.perform_async(target_account.id, follow_request.id, follow_request.class.name)
|
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
|
end
|
||||||
|
|
||||||
follow_request
|
follow_request
|
||||||
@ -58,10 +53,6 @@ class FollowService < BaseService
|
|||||||
|
|
||||||
if target_account.local?
|
if target_account.local?
|
||||||
LocalNotificationWorker.perform_async(target_account.id, follow.id, follow.class.name)
|
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
|
end
|
||||||
|
|
||||||
MergeWorker.perform_async(target_account.id, source_account.id)
|
MergeWorker.perform_async(target_account.id, source_account.id)
|
||||||
@ -69,19 +60,4 @@ class FollowService < BaseService
|
|||||||
follow
|
follow
|
||||||
end
|
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
|
end
|
||||||
|
@ -48,27 +48,9 @@ class ProcessMentionsService < BaseService
|
|||||||
|
|
||||||
if mentioned_account.local?
|
if mentioned_account.local?
|
||||||
LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name)
|
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
|
||||||
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
|
def resolve_account_service
|
||||||
ResolveAccountService.new
|
ResolveAccountService.new
|
||||||
end
|
end
|
||||||
|
@ -18,10 +18,6 @@ class ProcessQuoteService < BaseService
|
|||||||
|
|
||||||
if quoted_status.account.local?
|
if quoted_status.account.local?
|
||||||
LocalNotificationWorker.perform_async(quoted_status.account_id, status.id, status.class.name)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,12 +27,5 @@ class ProcessQuoteService < BaseService
|
|||||||
PotentialFriendshipTracker.record(status.account_id, status.quote.account_id, :reblog)
|
PotentialFriendshipTracker.record(status.account_id, status.quote.account_id, :reblog)
|
||||||
end
|
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
|
end
|
||||||
|
|
@ -40,10 +40,6 @@ class ReblogService < BaseService
|
|||||||
|
|
||||||
if reblogged_status.account.local?
|
if reblogged_status.account.local?
|
||||||
LocalNotificationWorker.perform_async(reblogged_status.account_id, reblog.id, reblog.class.name)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,11 +49,4 @@ class ReblogService < BaseService
|
|||||||
PotentialFriendshipTracker.record(account.id, reblog.reblog.account_id, :reblog)
|
PotentialFriendshipTracker.record(account.id, reblog.reblog.account_id, :reblog)
|
||||||
end
|
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
|
end
|
||||||
|
@ -4,29 +4,6 @@ class RejectFollowService < BaseService
|
|||||||
def call(source_account, target_account)
|
def call(source_account, target_account)
|
||||||
follow_request = FollowRequest.find_by!(account: source_account, target_account: target_account)
|
follow_request = FollowRequest.find_by!(account: source_account, target_account: target_account)
|
||||||
follow_request.reject!
|
follow_request.reject!
|
||||||
create_notification(follow_request) unless source_account.local?
|
|
||||||
follow_request
|
follow_request
|
||||||
end
|
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
|
end
|
||||||
|
@ -69,8 +69,6 @@ class SuspendAccountService < BaseService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def purge_content!
|
def purge_content!
|
||||||
distribute_delete_actor! if @account.local? && !@options[:skip_distribution]
|
|
||||||
|
|
||||||
@account.statuses.reorder(nil).find_in_batches do |statuses|
|
@account.statuses.reorder(nil).find_in_batches do |statuses|
|
||||||
BatchedRemoveStatusService.new.call(statuses, skip_side_effects: @options[:destroy])
|
BatchedRemoveStatusService.new.call(statuses, skip_side_effects: @options[:destroy])
|
||||||
end
|
end
|
||||||
@ -108,16 +106,6 @@ class SuspendAccountService < BaseService
|
|||||||
association.in_batches.destroy_all
|
association.in_batches.destroy_all
|
||||||
end
|
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
|
def delete_actor_json
|
||||||
return @delete_actor_json if defined?(@delete_actor_json)
|
return @delete_actor_json if defined?(@delete_actor_json)
|
||||||
|
|
||||||
|
@ -5,29 +5,6 @@ class UnblockService < BaseService
|
|||||||
return unless account.blocking?(target_account)
|
return unless account.blocking?(target_account)
|
||||||
|
|
||||||
unblock = account.unblock!(target_account)
|
unblock = account.unblock!(target_account)
|
||||||
create_notification(unblock) unless target_account.local?
|
|
||||||
unblock
|
unblock
|
||||||
end
|
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
|
end
|
||||||
|
@ -4,31 +4,6 @@ class UnfavouriteService < BaseService
|
|||||||
def call(account, status)
|
def call(account, status)
|
||||||
favourite = Favourite.find_by!(account: account, status: status)
|
favourite = Favourite.find_by!(account: account, status: status)
|
||||||
favourite.destroy!
|
favourite.destroy!
|
||||||
create_notification(favourite) unless status.local?
|
|
||||||
favourite
|
favourite
|
||||||
end
|
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
|
end
|
||||||
|
@ -19,8 +19,6 @@ class UnfollowService < BaseService
|
|||||||
return unless follow
|
return unless follow
|
||||||
|
|
||||||
follow.destroy!
|
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)
|
UnmergeWorker.perform_async(@target_account.id, @source_account.id)
|
||||||
follow
|
follow
|
||||||
end
|
end
|
||||||
@ -31,41 +29,7 @@ class UnfollowService < BaseService
|
|||||||
return unless follow_request
|
return unless follow_request
|
||||||
|
|
||||||
follow_request.destroy!
|
follow_request.destroy!
|
||||||
create_notification(follow_request) unless @target_account.local?
|
|
||||||
follow_request
|
follow_request
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user