dispatcher#post should not take opts
This commit is contained in:
parent
da9e57b2c9
commit
c23e6d9afd
4 changed files with 18 additions and 30 deletions
|
|
@ -237,9 +237,8 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def dispatch_post(post, opts = {})
|
||||
additional_people = opts.delete(:additional_subscribers)
|
||||
mailman = Postzord::Dispatcher.build(self, post, :additional_subscribers => additional_people)
|
||||
mailman.post(opts)
|
||||
mailman = Postzord::Dispatcher.build(self, post, opts)
|
||||
mailman.post
|
||||
end
|
||||
|
||||
def update_post(post, post_hash = {})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,20 @@ class Postzord::Dispatcher
|
|||
require File.join(Rails.root, 'lib/postzord/dispatcher/private')
|
||||
require File.join(Rails.root, 'lib/postzord/dispatcher/public')
|
||||
|
||||
attr_reader :sender, :object, :xml, :subscribers
|
||||
attr_reader :sender, :object, :xml, :subscribers, :opts
|
||||
|
||||
# @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
|
||||
@opts = opts
|
||||
|
||||
additional_subscribers = opts[:additional_subscribers] || []
|
||||
@subscribers = subscribers_from_object | [*additional_subscribers]
|
||||
end
|
||||
|
||||
# @return [Postzord::Dispatcher] Public or private dispatcher depending on the object's intended audience
|
||||
def self.build(user, object, opts={})
|
||||
|
|
@ -33,9 +46,9 @@ class Postzord::Dispatcher
|
|||
end
|
||||
|
||||
# @return [Object]
|
||||
def post(opts={})
|
||||
def post
|
||||
self.post_to_subscribers if @subscribers.present?
|
||||
self.deliver_to_services(opts[:url], opts[:services] || [])
|
||||
self.deliver_to_services(@opts[:url], @opts[:services] || [])
|
||||
self.process_after_dispatch_hooks
|
||||
@object
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,18 +4,6 @@
|
|||
|
||||
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]
|
||||
|
|
|
|||
|
|
@ -4,18 +4,6 @@
|
|||
|
||||
class Postzord::Dispatcher::Public < 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]
|
||||
|
|
|
|||
Loading…
Reference in a new issue