Skip to content
Snippets Groups Projects
Commit 3319473b authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Move PubSubHubbub pinging to a background worker

It can take as much as 0.5s if not longer to complete
parent 2febc6ed
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ class FavouriteService < BaseService
# @return [Favourite]
def call(account, status)
favourite = Favourite.create!(account: account, status: status)
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
HubPingWorker.perform_async(account.id)
if status.local?
NotificationMailer.favourite(status, account).deliver_later unless status.account.blocking?(account)
......
......@@ -17,7 +17,7 @@ class FollowService < BaseService
end
merge_into_timeline(target_account, source_account)
source_account.ping!(account_url(source_account, format: 'atom'), [Rails.configuration.x.hub_url])
HubPingWorker.perform_async(source_account.id)
follow
end
......
......@@ -10,7 +10,7 @@ class PostStatusService < BaseService
attach_media(status, media_ids)
process_mentions_service.call(status)
DistributionWorker.perform_async(status.id)
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
HubPingWorker.perform_async(account.id)
status
end
......
......@@ -6,7 +6,7 @@ class ReblogService < BaseService
def call(account, reblogged_status)
reblog = account.statuses.create!(reblog: reblogged_status, text: '')
DistributionWorker.perform_async(reblog.id)
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
HubPingWorker.perform_async(account.id)
if reblogged_status.local?
NotificationMailer.reblog(reblogged_status, account).deliver_later unless reblogged_status.account.blocking?(account)
......
class HubPingWorker
include Sidekiq::Worker
include RoutingHelper
def perform(account_id)
account = Account.find(account_id)
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment