Make a stranger that you receive a comment from visible
This commit is contained in:
parent
c629c23232
commit
831609ad15
2 changed files with 10 additions and 2 deletions
|
|
@ -9,10 +9,12 @@ class User
|
|||
key :friend_ids, Array
|
||||
key :pending_request_ids, Array
|
||||
key :visible_post_ids, Array
|
||||
key :visible_person_ids, Array
|
||||
|
||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||
|
||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
||||
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
||||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||
|
||||
|
|
@ -197,6 +199,8 @@ class User
|
|||
|
||||
elsif object.is_a?(Comment)
|
||||
object.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if object.person.nil?
|
||||
self.visible_people << object.person
|
||||
self.save
|
||||
Rails.logger.debug("The person parsed from comment xml is #{object.person.inspect}") unless object.person.nil?
|
||||
object.person.save
|
||||
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||
|
|
@ -244,7 +248,8 @@ class User
|
|||
def visible_person_by_id( id )
|
||||
id = id.to_id
|
||||
return self.person if id == self.person.id
|
||||
friends.detect{|x| x.id == id }
|
||||
result = friends.detect{|x| x.id == id }
|
||||
result = visible_people.detect{|x| x.id == id } unless result
|
||||
end
|
||||
|
||||
def group_by_id( id )
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ describe User do
|
|||
end
|
||||
|
||||
describe 'comments' do
|
||||
it 'should correctly marshal to the downstream user' do
|
||||
it 'should correctly marshal a stranger for the downstream user' do
|
||||
|
||||
friend_users(@user, @group, @user3, @group3)
|
||||
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||
|
|
@ -147,6 +147,8 @@ describe User do
|
|||
@user.receive comment.to_diaspora_xml
|
||||
@user.reload
|
||||
|
||||
commenter_id = @user2.person.id
|
||||
|
||||
@user2.person.delete
|
||||
@user2.delete
|
||||
comment_id = comment.id
|
||||
|
|
@ -160,6 +162,7 @@ describe User do
|
|||
new_comment.person.should_not be_nil
|
||||
new_comment.person.profile.should_not be_nil
|
||||
|
||||
@user3.visible_person_by_id(commenter_id).should_not be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue