DG IZ; moved commenting methods into User (from Person).
This commit is contained in:
parent
2a90e59f1e
commit
b5c6bbd1df
2 changed files with 26 additions and 29 deletions
|
|
@ -58,35 +58,6 @@ class Person
|
|||
encryption_key.public_key.export
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
######## Commenting ########
|
||||
def comment(text, options = {})
|
||||
raise "must comment on something!" unless options[:on]
|
||||
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
|
||||
c.creator_signature = c.sign_with_key(encryption_key)
|
||||
if c.save
|
||||
dispatch_comment c
|
||||
|
||||
c.socket_to_uid owner.id if owner_id
|
||||
c
|
||||
else
|
||||
Rails.logger.warn "this failed to save: #{c.inspect}"
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def dispatch_comment( c )
|
||||
if owns? c.post
|
||||
c.post_creator_signature = c.sign_with_key(encryption_key)
|
||||
c.save
|
||||
c.push_downstream
|
||||
elsif owns? c
|
||||
c.save
|
||||
c.push_upstream
|
||||
end
|
||||
end
|
||||
##profile
|
||||
def update_profile(params)
|
||||
if self.update_attributes(params)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,32 @@ class User
|
|||
self.posts.find_all_by_person_id( (group.person_ids + [self.person.id] ), :order => "created_at desc")
|
||||
end
|
||||
end
|
||||
|
||||
######## Commenting ########
|
||||
def comment(text, options = {})
|
||||
raise "must comment on something!" unless options[:on]
|
||||
c = Comment.new(:person_id => self.person.id, :text => text, :post => options[:on])
|
||||
c.creator_signature = c.sign_with_key(encryption_key)
|
||||
if c.save
|
||||
dispatch_comment c
|
||||
c.socket_to_uid id
|
||||
c
|
||||
else
|
||||
Rails.logger.warn "this failed to save: #{c.inspect}"
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def dispatch_comment( c )
|
||||
if owns? c.post
|
||||
c.post_creator_signature = c.sign_with_key(encryption_key)
|
||||
c.save
|
||||
c.push_downstream
|
||||
elsif owns? c
|
||||
c.save
|
||||
c.push_upstream
|
||||
end
|
||||
end
|
||||
|
||||
######### Posts and Such ###############
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue