From 2388237174d57605792e8c320c5e34dfe722eaea Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 4 Aug 2010 16:36:08 -0700 Subject: [PATCH 1/5] RS, IZ; Replace type_name method with object.class.to_s --- app/models/retraction.rb | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 2e9a29f77..7683e8ccb 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -6,7 +6,7 @@ class Retraction retraction = self.new retraction.post_id= object.id retraction.person_id = person_id_from(object) - retraction.type = self.type_name(object) + retraction.type = object.class.to_s retraction end @@ -19,7 +19,11 @@ class Retraction attr_accessor :type def perform - self.type.constantize.destroy(self.post_id) + begin + self.type.constantize.destroy(self.post_id) + rescue NameError + Rails.logger.info("Retraction for unknown type recieved.") + end end def self.person_id_from(object) @@ -30,15 +34,4 @@ class Retraction end end - - def self.type_name(object) - if object.is_a? Post - object.class - elsif object.is_a? Person - 'Person' - else - 'Clowntown' - end - end - end From 5a802299d57234647b15b7cce24309ef2e78a875 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 4 Aug 2010 17:06:15 -0700 Subject: [PATCH 2/5] IZ, RS; Retractions should now be signed --- app/models/retraction.rb | 27 +++++++++++++++++++++++++++ lib/encryptable.rb | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 7683e8ccb..5679822f0 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -1,6 +1,7 @@ class Retraction include ROXML include Diaspora::Webhooks + include Encryptable def self.for(object) retraction = self.new @@ -19,6 +20,8 @@ class Retraction attr_accessor :type def perform + return unless verify_signature(@creator_signature, Post.first(:id => post_id).person.id) + begin self.type.constantize.destroy(self.post_id) rescue NameError @@ -34,4 +37,28 @@ class Retraction end end +#ENCRYPTION + xml_reader :creator_signature + + def creator_signature + @creator_signature ||= sign if person_id == User.owner.id + end + + def creator_signature= input + @creator_signature = input + end + + def signable_accessors + accessors = self.class.roxml_attrs.collect{|definition| + definition.accessor} + accessors.delete 'person' + accessors.delete 'creator_signature' + accessors + end + + def signable_string + signable_accessors.collect{|accessor| + (self.send accessor.to_sym).to_s}.join ';' + end + end diff --git a/lib/encryptable.rb b/lib/encryptable.rb index 98ffdd7a2..632c3e6a2 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -31,7 +31,7 @@ end def sign_with_key(key) - Rails.logger.info("Signing #{signable_string} with key for person #{self.person.real_name}") + Rails.logger.info("Signing #{signable_string}") GPGME::sign(signable_string,nil, {:armor=> true, :mode => GPGME::SIG_MODE_DETACH, :signers => [key]}) end From 7676179e548ae192614bf4ca7f91198567985db2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 4 Aug 2010 17:10:38 -0700 Subject: [PATCH 3/5] IZ, RS; now passing correct object to verify_signature --- app/models/retraction.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 5679822f0..b096be75d 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -20,7 +20,7 @@ class Retraction attr_accessor :type def perform - return unless verify_signature(@creator_signature, Post.first(:id => post_id).person.id) + return unless verify_signature(@creator_signature, Post.first(:id => post_id).person) begin self.type.constantize.destroy(self.post_id) From 6832c67a786a6b19ecafb87dbd0f109d1283f55b Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 4 Aug 2010 17:20:29 -0700 Subject: [PATCH 4/5] RS IZ friend requests are hopefully now signed --- app/models/request.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/models/request.rb b/app/models/request.rb index 5a81be719..f39d1267f 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -3,6 +3,7 @@ class Request include MongoMapper::Document include Diaspora::Webhooks include ROXML + include Encryptable xml_accessor :_id xml_accessor :person, :as => Person @@ -38,7 +39,26 @@ class Request p.save end +#ENCRYPTION + before_validation :sign_if_mine + validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} + + xml_accessor :creator_signature + key :creator_signature, String + + def signable_accessors + accessors = self.class.roxml_attrs.collect{|definition| + definition.accessor} + accessors.delete 'person' + accessors.delete 'creator_signature' + accessors + end + def signable_string + signable_accessors.collect{|accessor| + (self.send accessor.to_sym).to_s}.join ';' + end + protected def clean_link From b74438a5dc0843a13563937b37ea292873fd6f90 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 4 Aug 2010 18:12:12 -0700 Subject: [PATCH 5/5] Made comments a little easier to see, especially on photo show page --- public/stylesheets/application.css | 5 +++-- public/stylesheets/sass/application.sass | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3f0cf9e93..9335a088f 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -206,11 +206,12 @@ ul.comment_set { padding: 0.6em; border-bottom: 1px solid #cccccc; } ul.comment_set li.comment .from { - color: #666666; font-weight: normal; } ul.comment_set li.comment .from a { - color: #333333; font-weight: bold; } + ul.comment_set li.comment div.time { + color: #666666; + font-size: 70%; } ul.comment_set li.comment form { margin-top: -5px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index fb2204dd5..0225b383a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -249,13 +249,15 @@ ul.comment_set :bottom 1px solid #ccc .from - :color #666 :font :weight normal a - :color #333 :font :weight bold + + div.time + :color #666 + :font-size 70% form :margin