fixing N socketing bug
This commit is contained in:
parent
07c216f31b
commit
b19cdf2e25
2 changed files with 16 additions and 9 deletions
|
|
@ -20,7 +20,6 @@ module Diaspora
|
|||
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
|
||||
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||
|
||||
|
||||
if object.is_a?(Comment) || object.is_a?(Post)
|
||||
e = EMWebfinger.new(object.diaspora_handle)
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ module Diaspora
|
|||
|
||||
raise "Not friends with that person" unless self.contact_for(salmon_author)
|
||||
|
||||
if object.is_a?(Comment)
|
||||
if object.is_a?(Comment)
|
||||
receive_comment object, xml
|
||||
else
|
||||
receive_post object, xml
|
||||
|
|
@ -137,11 +136,11 @@ module Diaspora
|
|||
self.save
|
||||
|
||||
aspects = self.aspects_with_person(post.person)
|
||||
aspects.each{ |aspect|
|
||||
aspects.each do |aspect|
|
||||
aspect.posts << post
|
||||
aspect.save
|
||||
post.socket_to_uid(id, :aspect_ids => [aspect.id]) if (post.respond_to?(:socket_to_uid) && !self.owns?(post))
|
||||
}
|
||||
end
|
||||
post.socket_to_uid(id, :aspect_ids => aspects.map(&:id)) if (post.respond_to?(:socket_to_uid) && !self.owns?(post))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ describe User do
|
|||
friend_users(user, aspect, user2, aspect2)
|
||||
end
|
||||
|
||||
it 'should stream only one message to the everyone aspect when a multi-aspected friend posts' do
|
||||
user.add_person_to_aspect(user2.person.id, user.aspect(:name => "villains").id)
|
||||
status = user2.post(:status_message, :message => "Users do things", :to => aspect2.id)
|
||||
xml = status.to_diaspora_xml
|
||||
Diaspora::WebSocket.should_receive(:queue_to_user).exactly(:once)
|
||||
user.receive xml, user2.person
|
||||
end
|
||||
|
||||
it 'should be able to parse and store a status message from xml' do
|
||||
status_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id
|
||||
|
||||
|
|
@ -113,11 +121,11 @@ describe User do
|
|||
post_in_db.comments.should == []
|
||||
user2.receive_salmon(@xml)
|
||||
post_in_db.reload
|
||||
|
||||
|
||||
post_in_db.comments.include?(@comment).should be true
|
||||
post_in_db.comments.first.person.should == local_person
|
||||
end
|
||||
|
||||
|
||||
it 'should correctly marshal a stranger for the downstream user' do
|
||||
remote_person = user3.person
|
||||
remote_person.delete
|
||||
|
|
@ -127,13 +135,13 @@ describe User do
|
|||
Person.should_receive(:by_account_identifier).twice.and_return{ |handle| if handle == user.person.diaspora_handle; user.person.save
|
||||
user.person; else; remote_person.save; remote_person; end }
|
||||
|
||||
|
||||
|
||||
user2.reload.raw_visible_posts.size.should == 1
|
||||
post_in_db = user2.raw_visible_posts.first
|
||||
post_in_db.comments.should == []
|
||||
user2.receive_salmon(@xml)
|
||||
post_in_db.reload
|
||||
|
||||
|
||||
post_in_db.comments.include?(@comment).should be true
|
||||
post_in_db.comments.first.person.should == remote_person
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue