diff --git a/app/models/comment.rb b/app/models/comment.rb index e3084553fca0b93dfbc7df9a8cbcec33a01d18c7..f0d829dd4a2b15e743e47a4d7a679c99e3caa953 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -9,8 +9,8 @@ class Comment < ActiveRecord::Base include ROXML include Diaspora::Webhooks - include Diaspora::Relayable include Diaspora::Guid + include Diaspora::Relayable include Diaspora::Socketable diff --git a/app/models/like.rb b/app/models/like.rb index baf4b0ff0e9fb8936adc3466ca2210bf64ee0c42..156775e445f1ebb8a02874dece00cd1b460f73f4 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -7,8 +7,8 @@ class Like < ActiveRecord::Base include ROXML include Diaspora::Webhooks - include Diaspora::Relayable include Diaspora::Guid + include Diaspora::Relayable include Diaspora::Socketable diff --git a/app/models/user.rb b/app/models/user.rb index bd7da12976266f6c790034db17d9b41e24beb420..c7184d3ecb9c503ce2f297559b4f76dd10a3eff5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -154,18 +154,10 @@ class User < ActiveRecord::Base end def build_relayable(model, options = {}) - m = model.new(options.merge(:author_id => self.person.id)) - m.set_guid - - #sign relayable as model creator - m.author_signature = m.sign_with_key(self.encryption_key) - - if !m.post_id.blank? && person.owns?(m.parent) - #sign relayable as parent object owner - m.parent_author_signature = m.sign_with_key(self.encryption_key) - end - - m + r = model.new(options.merge(:author_id => self.person.id)) + r.set_guid + r.initialize_signatures + r end ######## Commenting ######## diff --git a/lib/diaspora/relayable.rb b/lib/diaspora/relayable.rb index 44798d242340ccab1588d1e1443d646be5242a7e..d92a87ab888c72f61899396f5ee878a3ef637a5e 100644 --- a/lib/diaspora/relayable.rb +++ b/lib/diaspora/relayable.rb @@ -64,6 +64,16 @@ module Diaspora self end + def initialize_signatures + #sign relayable as model creator + self.author_signature = self.sign_with_key(author.owner.encryption_key) + + if !self.post_id.blank? && self.author.owns?(self.parent) + #sign relayable as parent object owner + self.parent_author_signature = sign_with_key(author.owner.encryption_key) + end + end + def verify_parent_author_signature verify_signature(self.parent_author_signature, self.parent.author) end