Comments pushing in the right directions
This commit is contained in:
parent
fa2e621b0f
commit
b0537e2f34
4 changed files with 17 additions and 9 deletions
|
|
@ -66,7 +66,14 @@ class Person
|
||||||
raise "must comment on something!" unless options[:on]
|
raise "must comment on something!" unless options[:on]
|
||||||
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
|
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
|
||||||
if c.save
|
if c.save
|
||||||
|
begin
|
||||||
dispatch_comment c
|
dispatch_comment c
|
||||||
|
rescue Exception => e
|
||||||
|
puts e.inspect
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
c.socket_to_uid owner.id if owner_id
|
c.socket_to_uid owner.id if owner_id
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
|
@ -77,7 +84,7 @@ class Person
|
||||||
|
|
||||||
def dispatch_comment( c )
|
def dispatch_comment( c )
|
||||||
if owns? c.post
|
if owns? c.post
|
||||||
push_downstream
|
c.push_downstream
|
||||||
elsif owns? c
|
elsif owns? c
|
||||||
c.push_upstream
|
c.push_upstream
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ class User
|
||||||
Rails.logger.debug("Saving object: #{object}")
|
Rails.logger.debug("Saving object: #{object}")
|
||||||
object.save
|
object.save
|
||||||
object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||||
object.person.dispatch_comment object if object.is_a?(Comment)
|
dispatch_comment object if object.is_a?(Comment) && !owns?(object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,24 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
|
remote_url = "http://tom.joindiaspora.com/"
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.create( :email => "tom@tom.joindiaspora.com",
|
user = User.create!( :email => "tom@tom.joindiaspora.com",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:person => Person.new(
|
:person => Person.new(
|
||||||
:email => "tom@tom.joindiaspora.com",
|
:email => "tom@tom.joindiaspora.com",
|
||||||
:url => "http://tom.joindiaspora.com/",
|
:url => remote_url,
|
||||||
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
||||||
)
|
)
|
||||||
user.person.save
|
user.person.save!
|
||||||
|
|
||||||
user2 = User.create( :email => "korth@tom.joindiaspora.com",
|
user2 = User.create!( :email => "korth@tom.joindiaspora.com",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:person => Person.new( :email => "korth@tom.joindiaspora.com",
|
:person => Person.new( :email => "korth@tom.joindiaspora.com",
|
||||||
:url => "http://tom.joindiaspora.com/",
|
:url => remote_url,
|
||||||
:profile => Profile.new( :first_name => "Evan",
|
:profile => Profile.new( :first_name => "Evan",
|
||||||
:last_name => "Korth")))
|
:last_name => "Korth")))
|
||||||
|
|
||||||
user2.person.save
|
user2.person.save!
|
||||||
|
|
||||||
# friending users
|
# friending users
|
||||||
group = user.group(:name => "other dudes")
|
group = user.group(:name => "other dudes")
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.unsubscribe(uid,sid)
|
def self.unsubscribe(uid,sid)
|
||||||
Rails.logger.debug "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}"
|
Rails.logger.debug "Unsubscribing socket #{sid} from #{uid}"
|
||||||
@channels[uid][0].unsubscribe(sid) if @channels[uid]
|
@channels[uid][0].unsubscribe(sid) if @channels[uid]
|
||||||
@channels[uid][1] -= 1
|
@channels[uid][1] -= 1
|
||||||
if @channels[uid][1] <= 0
|
if @channels[uid][1] <= 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue