From e4af2ccb1fa4ce82087b4cb7dfb401b3cc7e6800 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 14:22:14 -0700 Subject: [PATCH] Rename send_comment to dispatch_comment, simplify it --- app/models/person.rb | 23 ++++++----------------- app/models/user.rb | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 01947bcd6..7e0c2d3bb 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -66,7 +66,7 @@ class Person raise "must comment on something!" unless options[:on] c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save - send_comment c + dispatch_comment c c.socket_to_uid owner.id if owner_id true else @@ -75,22 +75,11 @@ class Person false end - def send_comment( c ) - if self.remote? - if c.post.person.owner.nil? - Rails.logger.info "The commenter is not here, and neither is the poster" - elsif c.post.person.owner - Rails.logger.info "The commenter is not here, and the poster is" - c.push_downstream - end - else - if owns? c.post - Rails.logger.info "The commenter is here, and is the poster" - c.push_downstream - else - Rails.logger.info "The commenter is here, and is not the poster" - c.push_upstream - end + def dispatch_comment( c ) + if owns? c.post + push_downstream + elsif owns? c + c.push_upstream end end ##profile diff --git a/app/models/user.rb b/app/models/user.rb index aa4526edd..ac8a98d76 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) - object.person.send_comment object if (object.is_a?(Comment) && self.owns?( object.post)) + object.person.dispatch_comment object if (object.is_a?(Comment) end end