parent
d551e43a9b
commit
149887a0ff
@ -0,0 +1,11 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class AuthorizeFollowService < BaseService |
||||
include StreamEntryRenderer |
||||
|
||||
def call(source_account, target_account) |
||||
follow_request = FollowRequest.find_by!(account: source_account, target_account: target_account) |
||||
follow_request.authorize! |
||||
NotificationWorker.perform_async(stream_entry_to_xml(follow_request.stream_entry), target_account.id, source_account.id) unless source_account.local? |
||||
end |
||||
end |
@ -0,0 +1,8 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
module StreamEntryRenderer |
||||
def stream_entry_to_xml(stream_entry) |
||||
renderer = StreamEntriesController.renderer.new(method: 'get', http_host: Rails.configuration.x.local_domain, https: Rails.configuration.x.use_https) |
||||
renderer.render(:show, assigns: { stream_entry: stream_entry }, formats: [:atom]) |
||||
end |
||||
end |
@ -0,0 +1,11 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class RejectFollowService < BaseService |
||||
include StreamEntryRenderer |
||||
|
||||
def call(source_account, target_account) |
||||
follow_request = FollowRequest.find_by!(account: source_account, target_account: target_account) |
||||
follow_request.reject! |
||||
NotificationWorker.perform_async(stream_entry_to_xml(follow_request.stream_entry), target_account.id, source_account.id) unless source_account.local? |
||||
end |
||||
end |
@ -1,10 +1,12 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class UnblockService < BaseService |
||||
include StreamEntryRenderer |
||||
|
||||
def call(account, target_account) |
||||
return unless account.blocking?(target_account) |
||||
|
||||
unblock = account.unblock!(target_account) |
||||
NotificationWorker.perform_async(unblock.stream_entry.id, target_account.id) unless target_account.local? |
||||
NotificationWorker.perform_async(stream_entry_to_xml(unblock.stream_entry), account.id, target_account.id) unless target_account.local? |
||||
end |
||||
end |
||||
|
@ -1,12 +1,14 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class UnfollowService < BaseService |
||||
include StreamEntryRenderer |
||||
|
||||
# Unfollow and notify the remote user |
||||
# @param [Account] source_account Where to unfollow from |
||||
# @param [Account] target_account Which to unfollow |
||||
def call(source_account, target_account) |
||||
follow = source_account.unfollow!(target_account) |
||||
NotificationWorker.perform_async(follow.stream_entry.id, target_account.id) unless target_account.local? |
||||
NotificationWorker.perform_async(stream_entry_to_xml(follow.stream_entry), source_account.id, target_account.id) unless target_account.local? |
||||
UnmergeWorker.perform_async(target_account.id, source_account.id) |
||||
end |
||||
end |
||||
|
@ -1,11 +0,0 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class PushNotificationWorker |
||||
include Sidekiq::Worker |
||||
|
||||
def perform(notification_id) |
||||
SendPushNotificationService.new.call(Notification.find(notification_id)) |
||||
rescue ActiveRecord::RecordNotFound |
||||
true |
||||
end |
||||
end |
Loading…
Reference in new issue