|
@@ -7,7 +7,7 @@ class FollowService < BaseService
|
|
# @param [Account] source_account From which to follow
|
|
# @param [Account] source_account From which to follow
|
|
# @param [String] uri User URI to follow in the form of username@domain
|
|
# @param [String] uri User URI to follow in the form of username@domain
|
|
def call(source_account, uri)
|
|
def call(source_account, uri)
|
|
- target_account = follow_remote_account_service.call(uri)
|
|
|
|
|
|
+ target_account = FollowRemoteAccountService.new.call(uri)
|
|
|
|
|
|
raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
|
|
raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
|
|
raise Mastodon::NotPermitted if target_account.blocking?(source_account) || source_account.blocking?(target_account)
|
|
raise Mastodon::NotPermitted if target_account.blocking?(source_account) || source_account.blocking?(target_account)
|
|
@@ -27,7 +27,7 @@ class FollowService < BaseService
|
|
if target_account.local?
|
|
if target_account.local?
|
|
NotifyService.new.call(target_account, follow_request)
|
|
NotifyService.new.call(target_account, follow_request)
|
|
else
|
|
else
|
|
- NotificationWorker.perform_async(stream_entry_to_xml(follow_request.stream_entry), source_account.id, target_account.id)
|
|
|
|
|
|
+ NotificationWorker.perform_async(build_follow_request_xml(follow_request), source_account.id, target_account.id)
|
|
AfterRemoteFollowRequestWorker.perform_async(follow_request.id)
|
|
AfterRemoteFollowRequestWorker.perform_async(follow_request.id)
|
|
end
|
|
end
|
|
|
|
|
|
@@ -40,13 +40,12 @@ class FollowService < BaseService
|
|
if target_account.local?
|
|
if target_account.local?
|
|
NotifyService.new.call(target_account, follow)
|
|
NotifyService.new.call(target_account, follow)
|
|
else
|
|
else
|
|
- subscribe_service.call(target_account) unless target_account.subscribed?
|
|
|
|
- NotificationWorker.perform_async(stream_entry_to_xml(follow.stream_entry), source_account.id, target_account.id)
|
|
|
|
|
|
+ SubscribeService.new.call(target_account) unless target_account.subscribed?
|
|
|
|
+ NotificationWorker.perform_async(build_follow_xml(follow), source_account.id, target_account.id)
|
|
AfterRemoteFollowWorker.perform_async(follow.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)
|
|
- Pubsubhubbub::DistributionWorker.perform_async(follow.stream_entry.id)
|
|
|
|
|
|
|
|
follow
|
|
follow
|
|
end
|
|
end
|
|
@@ -55,11 +54,41 @@ class FollowService < BaseService
|
|
Redis.current
|
|
Redis.current
|
|
end
|
|
end
|
|
|
|
|
|
- def follow_remote_account_service
|
|
|
|
- @follow_remote_account_service ||= FollowRemoteAccountService.new
|
|
|
|
|
|
+ def build_follow_request_xml(follow_request)
|
|
|
|
+ Nokogiri::XML::Builder.new do |xml|
|
|
|
|
+ entry(xml, true) do
|
|
|
|
+ title xml, "#{follow_request.account.acct} requested to follow #{follow_request.target_account.acct}"
|
|
|
|
+
|
|
|
|
+ author(xml) do
|
|
|
|
+ include_author xml, follow_request.account
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ object_type xml, :activity
|
|
|
|
+ verb xml, :request_friend
|
|
|
|
+
|
|
|
|
+ target(xml) do
|
|
|
|
+ include_author xml, follow_request.target_account
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
+ end.to_xml
|
|
end
|
|
end
|
|
|
|
|
|
- def subscribe_service
|
|
|
|
- @subscribe_service ||= SubscribeService.new
|
|
|
|
|
|
+ def build_follow_xml(follow)
|
|
|
|
+ Nokogiri::XML::Builder.new do |xml|
|
|
|
|
+ entry(xml, true) do
|
|
|
|
+ title xml, "#{follow.account.acct} started following #{follow.target_account.acct}"
|
|
|
|
+
|
|
|
|
+ author(xml) do
|
|
|
|
+ include_author xml, follow.account
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ object_type xml, :activity
|
|
|
|
+ verb xml, :follow
|
|
|
|
+
|
|
|
|
+ target(xml) do
|
|
|
|
+ include_author xml, follow.target_account
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
+ end.to_xml
|
|
end
|
|
end
|
|
end
|
|
end
|