38 lines
1.3 KiB
Ruby
38 lines
1.3 KiB
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.
|
|
|
|
class Postzord::Dispatcher::Private < Postzord::Dispatcher
|
|
|
|
# @param user [User] User dispatching the object in question
|
|
# @param object [Object] The object to be sent to other Diaspora installations
|
|
# @opt additional_subscribers [Array<Person>] Additional subscribers
|
|
def initialize(user, object, opts={})
|
|
@sender = user
|
|
@object = object
|
|
@xml = @object.to_diaspora_xml
|
|
|
|
additional_subscribers = opts[:additional_subscribers] || []
|
|
@subscribers = subscribers_from_object | [*additional_subscribers]
|
|
end
|
|
|
|
# @param user [User]
|
|
# @param activity [String]
|
|
# @return [Salmon::EncryptedSlap]
|
|
def self.salmon(user, activity)
|
|
Salmon::EncryptedSlap.create_by_user_and_activity(user, activity)
|
|
end
|
|
|
|
# @param person [Person]
|
|
# @return [String]
|
|
def self.receive_url_for(person)
|
|
person.receive_url
|
|
end
|
|
|
|
# Enqueues a job in Resque
|
|
# @param remote_people [Array<Person>] Recipients of the post on other pods
|
|
# @return [void]
|
|
def queue_remote_delivery_job(remote_people)
|
|
Resque.enqueue(Job::HttpMulti, @sender.id, Base64.encode64(@object.to_diaspora_xml), remote_people.map{|p| p.id})
|
|
end
|
|
end
|