Remove parent author signature for relayables from the DB
since it is considered redundant
This commit is contained in:
parent
3d5aacda4c
commit
a2ce47fae5
5 changed files with 18 additions and 26 deletions
|
|
@ -21,11 +21,6 @@ class Message < ActiveRecord::Base
|
|||
# inside, which would cause an infinite recursion
|
||||
#sign comment as commenter
|
||||
self.author_signature = self.sign_with_key(self.author.owner.encryption_key) if self.author.owner
|
||||
|
||||
if self.author.owns?(self.parent)
|
||||
#sign comment as post owner
|
||||
self.parent_author_signature = self.sign_with_key(self.parent.author.owner.encryption_key) if self.parent.author.owner
|
||||
end
|
||||
self.save!
|
||||
self
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
class RemoveSignaturesFromRelayables < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :comments, :parent_author_signature, :text
|
||||
remove_column :poll_participations, :parent_author_signature, :text
|
||||
remove_column :messages, :parent_author_signature, :text
|
||||
remove_column :participations, :parent_author_signature, :text
|
||||
remove_column :likes, :parent_author_signature, :text
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151003142048) do
|
||||
ActiveRecord::Schema.define(version: 20151210213023) do
|
||||
|
||||
create_table "account_deletions", force: :cascade do |t|
|
||||
t.string "diaspora_handle", limit: 255
|
||||
|
|
@ -92,7 +92,6 @@ ActiveRecord::Schema.define(version: 20151003142048) do
|
|||
t.integer "author_id", limit: 4, null: false
|
||||
t.string "guid", limit: 255, null: false
|
||||
t.text "author_signature", limit: 65535
|
||||
t.text "parent_author_signature", limit: 65535
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "likes_count", limit: 4, default: 0, null: false
|
||||
|
|
@ -168,7 +167,6 @@ ActiveRecord::Schema.define(version: 20151003142048) do
|
|||
t.integer "author_id", limit: 4
|
||||
t.string "guid", limit: 255
|
||||
t.text "author_signature", limit: 65535
|
||||
t.text "parent_author_signature", limit: 65535
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "target_type", limit: 60, null: false
|
||||
|
|
@ -205,7 +203,6 @@ ActiveRecord::Schema.define(version: 20151003142048) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "author_signature", limit: 65535
|
||||
t.text "parent_author_signature", limit: 65535
|
||||
end
|
||||
|
||||
add_index "messages", ["author_id"], name: "index_messages_on_author_id", using: :btree
|
||||
|
|
@ -257,7 +254,6 @@ ActiveRecord::Schema.define(version: 20151003142048) do
|
|||
t.string "target_type", limit: 60, null: false
|
||||
t.integer "author_id", limit: 4
|
||||
t.text "author_signature", limit: 65535
|
||||
t.text "parent_author_signature", limit: 65535
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "count", limit: 4, default: 1, null: false
|
||||
|
|
@ -338,7 +334,6 @@ ActiveRecord::Schema.define(version: 20151003142048) do
|
|||
t.integer "poll_id", limit: 4, null: false
|
||||
t.string "guid", limit: 255
|
||||
t.text "author_signature", limit: 65535
|
||||
t.text "parent_author_signature", limit: 65535
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ module Diaspora
|
|||
|
||||
def self.included(model)
|
||||
model.class_eval do
|
||||
attr_writer :parent_author_signature
|
||||
|
||||
#these fields must be in the schema for a relayable model
|
||||
xml_attr :parent_guid
|
||||
xml_attr :parent_author_signature
|
||||
|
|
@ -77,7 +79,7 @@ module Diaspora
|
|||
|
||||
# Check to make sure the signature of the comment or like comes from the person claiming to author it
|
||||
unless comment_or_like.parent_author == user.person || comment_or_like.verify_parent_author_signature
|
||||
logger.warn "event=receive status=abort reason='object signature not valid' recipient=#{user.diaspora_handle} "\
|
||||
logger.warn "event=receive status=abort reason='sender is not valid' recipient=#{user.diaspora_handle} "\
|
||||
"sender=#{parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{parent.id}"
|
||||
return
|
||||
end
|
||||
|
|
@ -108,11 +110,13 @@ module Diaspora
|
|||
def initialize_signatures
|
||||
#sign relayable as model creator
|
||||
self.author_signature = self.sign_with_key(author.owner.encryption_key)
|
||||
end
|
||||
|
||||
if !self.parent.blank? && self.author.owns?(self.parent)
|
||||
#sign relayable as parent object owner
|
||||
self.parent_author_signature = sign_with_key(author.owner.encryption_key)
|
||||
def parent_author_signature
|
||||
unless parent.blank? || parent.author.owner.nil?
|
||||
@parent_author_signature = sign_with_key(parent.author.owner.encryption_key)
|
||||
end
|
||||
@parent_author_signature
|
||||
end
|
||||
|
||||
# @return [Boolean]
|
||||
|
|
|
|||
|
|
@ -61,11 +61,6 @@ shared_examples_for "it is relayable" do
|
|||
expect(@object_by_parent_author.verify_parent_author_signature).to be true
|
||||
end
|
||||
|
||||
it 'does not sign as the parent author is not parent' do
|
||||
@object_by_recipient.author_signature = @object_by_recipient.send(:sign_with_key, @local_leia.encryption_key)
|
||||
expect(@object_by_recipient.verify_parent_author_signature).to be false
|
||||
end
|
||||
|
||||
it 'should verify a object made on a remote post by a different contact' do
|
||||
@object_by_recipient.author_signature = @object_by_recipient.send(:sign_with_key, @local_leia.encryption_key)
|
||||
@object_by_recipient.parent_author_signature = @object_by_recipient.send(:sign_with_key, @local_luke.encryption_key)
|
||||
|
|
@ -90,12 +85,6 @@ shared_examples_for "it is relayable" do
|
|||
}.to_not change { @dup_object_by_parent_author.class.count }
|
||||
end
|
||||
|
||||
it 'does not process if post_creator_signature is invalid' do
|
||||
@object_by_parent_author.delete # remove object from db so we set a creator sig
|
||||
@dup_object_by_parent_author.parent_author_signature = "dsfadsfdsa"
|
||||
expect(@dup_object_by_parent_author.receive(@local_leia, @local_luke.person)).to eq(nil)
|
||||
end
|
||||
|
||||
it 'signs when the person receiving is the parent author' do
|
||||
@object_by_recipient.save
|
||||
@object_by_recipient.receive(@local_luke, @local_leia.person)
|
||||
|
|
|
|||
Loading…
Reference in a new issue