make entities more consistent
This commit is contained in:
parent
dc0f786b2c
commit
9d999918e5
13 changed files with 27 additions and 27 deletions
|
|
@ -34,11 +34,11 @@ module DiasporaFederation
|
||||||
# @return [String] target type
|
# @return [String] target type
|
||||||
property :target_type
|
property :target_type
|
||||||
|
|
||||||
# @!attribute [r] sender_id
|
# @!attribute [r] diaspora_id
|
||||||
# The diaspora ID of the person who deletes a post
|
# The diaspora ID of the person who deletes a post
|
||||||
# @see Person#diaspora_id
|
# @see Person#diaspora_id
|
||||||
# @return [String] diaspora ID
|
# @return [String] diaspora ID
|
||||||
property :sender_id, xml_name: :sender_handle
|
property :diaspora_id, xml_name: :sender_handle
|
||||||
|
|
||||||
# @!attribute [r] target_author_signature
|
# @!attribute [r] target_author_signature
|
||||||
# Contains a signature of the entity using the private key of the
|
# Contains a signature of the entity using the private key of the
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ module DiasporaFederation
|
||||||
#
|
#
|
||||||
# @see Validators::RetractionValidator
|
# @see Validators::RetractionValidator
|
||||||
class Retraction < Entity
|
class Retraction < Entity
|
||||||
# @!attribute [r] post_guid
|
# @!attribute [r] target_guid
|
||||||
# guid of a post to be deleted
|
# guid of the entity to be deleted
|
||||||
# @see HCard#guid
|
# @see HCard#guid
|
||||||
# @return [String] post guid
|
# @return [String] target guid
|
||||||
property :post_guid
|
property :target_guid, xml_name: :post_guid
|
||||||
|
|
||||||
# @!attribute [r] diaspora_id
|
# @!attribute [r] diaspora_id
|
||||||
# The diaspora ID of the person who deletes a post
|
# The diaspora ID of the person who deletes a post
|
||||||
|
|
@ -17,9 +17,9 @@ module DiasporaFederation
|
||||||
# @return [String] diaspora ID
|
# @return [String] diaspora ID
|
||||||
property :diaspora_id, xml_name: :diaspora_handle
|
property :diaspora_id, xml_name: :diaspora_handle
|
||||||
|
|
||||||
# @!attribute [r] type
|
# @!attribute [r] target_type
|
||||||
# @return [String] type
|
# @return [String] target type
|
||||||
property :type
|
property :target_type, xml_name: :type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ module DiasporaFederation
|
||||||
# @return [String] target type
|
# @return [String] target type
|
||||||
property :target_type
|
property :target_type
|
||||||
|
|
||||||
# @!attribute [r] sender_id
|
# @!attribute [r] diaspora_id
|
||||||
# The diaspora ID of the person who deletes a post
|
# The diaspora ID of the person who deletes a post
|
||||||
# @see Person#diaspora_id
|
# @see Person#diaspora_id
|
||||||
# @return [String] diaspora ID
|
# @return [String] diaspora ID
|
||||||
property :sender_id, xml_name: :sender_handle
|
property :diaspora_id, xml_name: :sender_handle
|
||||||
|
|
||||||
# @!attribute [r] author_signature
|
# @!attribute [r] author_signature
|
||||||
# Contains a signature of the entity using the private key of the author of a post
|
# Contains a signature of the entity using the private key of the author of a post
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ FactoryGirl.define do
|
||||||
parent_author_signature { generate(:signature) }
|
parent_author_signature { generate(:signature) }
|
||||||
target_guid { generate(:guid) }
|
target_guid { generate(:guid) }
|
||||||
target_type "Post"
|
target_type "Post"
|
||||||
sender_id { generate(:diaspora_id) }
|
diaspora_id
|
||||||
target_author_signature { generate(:signature) }
|
target_author_signature { generate(:signature) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -158,15 +158,15 @@ FactoryGirl.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
|
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
|
||||||
post_guid { generate(:guid) }
|
target_guid { generate(:guid) }
|
||||||
diaspora_id
|
diaspora_id
|
||||||
type "Post"
|
target_type "Post"
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
|
factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
|
||||||
target_guid { generate(:guid) }
|
target_guid { generate(:guid) }
|
||||||
target_type "Post"
|
target_type "Post"
|
||||||
sender_id { generate(:diaspora_id) }
|
diaspora_id
|
||||||
target_author_signature { generate(:signature) }
|
target_author_signature { generate(:signature) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
rule :target_type, :not_empty
|
rule :target_type, :not_empty
|
||||||
|
|
||||||
rule :sender_id, %i(not_empty diaspora_id)
|
rule :diaspora_id, %i(not_empty diaspora_id)
|
||||||
|
|
||||||
rule :target_author_signature, :not_empty
|
rule :target_author_signature, :not_empty
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ module DiasporaFederation
|
||||||
class RetractionValidator < Validation::Validator
|
class RetractionValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :post_guid, :guid
|
rule :target_guid, :guid
|
||||||
|
|
||||||
rule :diaspora_id, %i(not_empty diaspora_id)
|
rule :diaspora_id, %i(not_empty diaspora_id)
|
||||||
|
|
||||||
rule :type, :not_empty
|
rule :target_type, :not_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
rule :target_type, :not_empty
|
rule :target_type, :not_empty
|
||||||
|
|
||||||
rule :sender_id, %i(not_empty diaspora_id)
|
rule :diaspora_id, %i(not_empty diaspora_id)
|
||||||
|
|
||||||
rule :target_author_signature, :not_empty
|
rule :target_author_signature, :not_empty
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module DiasporaFederation
|
||||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||||
<target_guid>#{data[:target_guid]}</target_guid>
|
<target_guid>#{data[:target_guid]}</target_guid>
|
||||||
<target_type>#{data[:target_type]}</target_type>
|
<target_type>#{data[:target_type]}</target_type>
|
||||||
<sender_handle>#{data[:sender_id]}</sender_handle>
|
<sender_handle>#{data[:diaspora_id]}</sender_handle>
|
||||||
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
||||||
</relayable_retraction>
|
</relayable_retraction>
|
||||||
XML
|
XML
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ module DiasporaFederation
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
<retraction>
|
<retraction>
|
||||||
<post_guid>#{data[:post_guid]}</post_guid>
|
<post_guid>#{data[:target_guid]}</post_guid>
|
||||||
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
||||||
<type>#{data[:type]}</type>
|
<type>#{data[:target_type]}</type>
|
||||||
</retraction>
|
</retraction>
|
||||||
XML
|
XML
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ module DiasporaFederation
|
||||||
<signed_retraction>
|
<signed_retraction>
|
||||||
<target_guid>#{data[:target_guid]}</target_guid>
|
<target_guid>#{data[:target_guid]}</target_guid>
|
||||||
<target_type>#{data[:target_type]}</target_type>
|
<target_type>#{data[:target_type]}</target_type>
|
||||||
<sender_handle>#{data[:sender_id]}</sender_handle>
|
<sender_handle>#{data[:diaspora_id]}</sender_handle>
|
||||||
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
||||||
</signed_retraction>
|
</signed_retraction>
|
||||||
XML
|
XML
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
it_behaves_like "a common validator"
|
it_behaves_like "a common validator"
|
||||||
|
|
||||||
it_behaves_like "a diaspora id validator" do
|
it_behaves_like "a diaspora id validator" do
|
||||||
let(:property) { :sender_id }
|
let(:property) { :diaspora_id }
|
||||||
let(:mandatory) { true }
|
let(:mandatory) { true }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
it_behaves_like "a common validator"
|
it_behaves_like "a common validator"
|
||||||
|
|
||||||
it_behaves_like "a guid validator" do
|
it_behaves_like "a guid validator" do
|
||||||
let(:property) { :post_guid }
|
let(:property) { :target_guid }
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like "a diaspora id validator" do
|
it_behaves_like "a diaspora id validator" do
|
||||||
|
|
@ -14,7 +14,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
describe "#type" do
|
describe "#type" do
|
||||||
it_behaves_like "a property that mustn't be empty" do
|
it_behaves_like "a property that mustn't be empty" do
|
||||||
let(:property) { :type }
|
let(:property) { :target_type }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
it_behaves_like "a common validator"
|
it_behaves_like "a common validator"
|
||||||
|
|
||||||
it_behaves_like "a diaspora id validator" do
|
it_behaves_like "a diaspora id validator" do
|
||||||
let(:property) { :sender_id }
|
let(:property) { :diaspora_id }
|
||||||
let(:mandatory) { true }
|
let(:mandatory) { true }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue