Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
034755368b
7 changed files with 33 additions and 12 deletions
|
|
@ -22,10 +22,15 @@ class PublicsController < ApplicationController
|
|||
end
|
||||
|
||||
def receive
|
||||
@user = Person.first(:id => params[:id]).owner
|
||||
render :nothing => true
|
||||
begin
|
||||
@user = Person.first(:id => params[:id]).owner
|
||||
rescue NoMethodError => e
|
||||
Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}")
|
||||
return
|
||||
end
|
||||
Rails.logger.debug "PublicsController has received: #{params[:xml]}"
|
||||
@user.receive params[:xml] if params[:xml]
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class Album
|
|||
|
||||
def self.mine_or_friends(friend_param, current_user)
|
||||
if friend_param
|
||||
puts "i am working"
|
||||
Album.find_all_by_person_id(current_user.friend_ids)
|
||||
else
|
||||
current_user.person.albums
|
||||
|
|
@ -67,6 +68,6 @@ class Album
|
|||
end
|
||||
|
||||
def propagate_retraction
|
||||
Retraction.for(self).notify_people
|
||||
self.person.owner.retract(self)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ class Group
|
|||
include MongoMapper::Document
|
||||
|
||||
key :name, String
|
||||
validates_presence_of :name
|
||||
|
||||
key :person_ids, Array
|
||||
key :request_ids, Array
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Person
|
|||
|
||||
timestamps!
|
||||
|
||||
after_destroy :remove_all_traces
|
||||
before_destroy :remove_all_traces
|
||||
before_validation :clean_url
|
||||
validates_presence_of :email, :url, :profile, :serialized_key
|
||||
validates_format_of :url, :with =>
|
||||
|
|
@ -92,5 +92,6 @@ class Person
|
|||
private
|
||||
def remove_all_traces
|
||||
Post.all(:person_id => id).each{|p| p.delete}
|
||||
Album.all(:person_id => id).each{|p| p.delete}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ class User
|
|||
######### Posts and Such ###############
|
||||
|
||||
def retract( post )
|
||||
post.unsocket_from_uid(self.id) if post.respond_to? :unsocket_from_uid
|
||||
retraction = Retraction.for(post)
|
||||
retraction.creator_signature = retraction.sign_with_key( encryption_key )
|
||||
retraction.notify_people
|
||||
|
|
@ -273,7 +274,7 @@ class User
|
|||
}
|
||||
|
||||
groups = groups_with_person(object.person)
|
||||
object.socket_to_uid(id, :group_id => groups.first.id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||
object.socket_to_uid(id, :group_id => group.id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -296,16 +297,19 @@ class User
|
|||
end
|
||||
|
||||
def visible_person_by_id( id )
|
||||
return self.person if ensure_bson(id) == self.person.id
|
||||
friends.detect{|x| x.id == ensure_bson( id ) }
|
||||
id = ensure_bson id
|
||||
return self.person if id == self.person.id
|
||||
friends.detect{|x| x.id == id }
|
||||
end
|
||||
|
||||
def group_by_id( id )
|
||||
groups.detect{|x| x.id == ensure_bson( id ) }
|
||||
id = ensure_bson id
|
||||
groups.detect{|x| x.id == id }
|
||||
end
|
||||
|
||||
def groups_with_person person
|
||||
groups.select {|group| group.person_ids.include? person.id}
|
||||
id = ensure_bson person.id
|
||||
groups.select {|group| group.person_ids.include? id}
|
||||
end
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -88,8 +88,5 @@ describe Album do
|
|||
it 'should have an id' do
|
||||
@xml.include?(@album.id.to_s).should be true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,6 +25,18 @@ describe User do
|
|||
Post.all(:person_id => person.id).first.message.should == 'store this!'
|
||||
StatusMessage.all.size.should == 1
|
||||
end
|
||||
|
||||
it 'should not create new groups on message receive' do
|
||||
num_groups = @user.groups.size
|
||||
|
||||
(0..5).each{ |n|
|
||||
status_message = @user2.post :status_message, :message => "store this #{n}!"
|
||||
xml = status_message.to_diaspora_xml
|
||||
@user.receive( xml )
|
||||
}
|
||||
|
||||
@user.groups.size.should == num_groups
|
||||
end
|
||||
|
||||
describe 'post refs' do
|
||||
before do
|
||||
|
|
|
|||
Loading…
Reference in a new issue