Skip to content
Extraits de code Groupes Projets
Valider 283e3767 rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Move initialize_signatures method out of user and into relayable

parent df04b598
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -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
......
......@@ -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 ########
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter