diaspora/app/workers/deferred_dispatch.rb
2016-06-26 06:21:01 +02:00

18 lines
629 B
Ruby

# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Workers
class DeferredDispatch < Base
sidekiq_options queue: :dispatch
def perform(user_id, object_class_name, object_id, opts)
user = User.find(user_id)
object = object_class_name.constantize.find(object_id)
opts = HashWithIndifferentAccess.new(opts)
Diaspora::Federation::Dispatcher.build(user, object, opts).dispatch
rescue ActiveRecord::RecordNotFound # The target got deleted before the job was run
end
end
end