parent
0ccd15cd53
commit
a082bcebff
5 changed files with 0 additions and 200 deletions
|
|
@ -49,5 +49,3 @@ require "diaspora_federation/entities/retraction"
|
|||
|
||||
# deprecated
|
||||
require "diaspora_federation/entities/request"
|
||||
require "diaspora_federation/entities/signed_retraction"
|
||||
require "diaspora_federation/entities/relayable_retraction"
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a claim of deletion of a previously federated
|
||||
# relayable entity. ({Entities::Comment}, {Entities::Like})
|
||||
#
|
||||
# There are two cases of federation of the RelayableRetraction.
|
||||
# Retraction from the dowstream object owner is when an author of the
|
||||
# relayable (e.g. Comment) deletes it themself. In this case only target_author_signature
|
||||
# is filled and a retraction is sent to the commented post's author. Here
|
||||
# the upstream object owner signs it with the parent's author key, puts
|
||||
# the signature in parent_author_signature and sends it to other pods where
|
||||
# other participating people are present. This is the second case - retraction
|
||||
# from the upstream object owner.
|
||||
# Retraction from the upstream object owner can also be performed by the
|
||||
# upstream object owner themself - they have a right to delete comments on their posts.
|
||||
# In any case in the retraction by the upstream author target_author_signature
|
||||
# is not checked, only parent_author_signature is checked.
|
||||
#
|
||||
# @see Validators::RelayableRetractionValidator
|
||||
# @deprecated will be replaced with {Entities::Retraction}
|
||||
class RelayableRetraction < Entity
|
||||
# @!attribute [r] parent_author_signature
|
||||
# Contains a signature of the entity using the private key of the author of a parent post.
|
||||
# This signature is mandatory only when federating from an upstream author to the subscribers.
|
||||
# @see Relayable#parent_author_signature
|
||||
# @return [String] parent author signature
|
||||
property :parent_author_signature, :string, default: nil
|
||||
|
||||
# @!attribute [r] target_guid
|
||||
# Guid of a relayable to be deleted
|
||||
# @see Comment#guid
|
||||
# @return [String] target guid
|
||||
property :target_guid, :string
|
||||
|
||||
# @!attribute [r] target_type
|
||||
# A string describing a type of the target
|
||||
# @see Retraction#target_type
|
||||
# @return [String] target type
|
||||
property :target_type, :string
|
||||
|
||||
# @!attribute [r] author
|
||||
# The diaspora* ID of the person who deletes a relayable
|
||||
# @see Person#author
|
||||
# @return [String] diaspora* ID
|
||||
property :author, :string, xml_name: :sender_handle
|
||||
|
||||
# @!attribute [r] target_author_signature
|
||||
# Contains a signature of the entity using the private key of the
|
||||
# author of a federated relayable entity. ({Entities::Comment}, {Entities::Like})
|
||||
# This signature is mandatory only when federation from the subscriber to an upstream
|
||||
# author is done.
|
||||
# @see Relayable#author_signature
|
||||
# @return [String] target author signature
|
||||
property :target_author_signature, :string, default: nil
|
||||
|
||||
def initialize(*)
|
||||
raise "Sending RelayableRetraction is not supported anymore! Use Retraction instead!"
|
||||
end
|
||||
|
||||
# @return [Retraction] instance
|
||||
def self.from_hash(hash)
|
||||
Retraction.from_hash(hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a claim of deletion of a previously federated
|
||||
# entity of post type. ({Entities::StatusMessage})
|
||||
#
|
||||
# @see Validators::SignedRetractionValidator
|
||||
# @deprecated will be replaced with {Entities::Retraction}
|
||||
class SignedRetraction < Entity
|
||||
# @!attribute [r] target_guid
|
||||
# Guid of a post to be deleted
|
||||
# @see Retraction#target_guid
|
||||
# @return [String] target guid
|
||||
property :target_guid, :string
|
||||
|
||||
# @!attribute [r] target_type
|
||||
# A string describing the type of the target
|
||||
# @see Retraction#target_type
|
||||
# @return [String] target type
|
||||
property :target_type, :string
|
||||
|
||||
# @!attribute [r] author
|
||||
# The diaspora* ID of the person who deletes a post
|
||||
# @see Person#author
|
||||
# @return [String] diaspora* ID
|
||||
property :author, :string, xml_name: :sender_handle
|
||||
|
||||
# @!attribute [r] author_signature
|
||||
# Contains a signature of the entity using the private key of the author of a post
|
||||
# This signature is mandatory.
|
||||
# @return [String] author signature
|
||||
property :target_author_signature, :string, default: nil
|
||||
|
||||
def initialize(*)
|
||||
raise "Sending SignedRetraction is not supported anymore! Use Retraction instead!"
|
||||
end
|
||||
|
||||
# @return [Retraction] instance
|
||||
def self.from_hash(hash)
|
||||
Retraction.from_hash(hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
describe Entities::RelayableRetraction do
|
||||
let(:target) { Fabricate(:comment, author: bob) }
|
||||
let(:target_entity) {
|
||||
Fabricate(
|
||||
:related_entity,
|
||||
author: bob.diaspora_id,
|
||||
parent: Fabricate(:related_entity, author: alice.diaspora_id)
|
||||
)
|
||||
}
|
||||
let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
|
||||
|
||||
let(:xml) { <<~XML }
|
||||
<relayable_retraction>
|
||||
<parent_author_signature/>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<target_author_signature/>
|
||||
</relayable_retraction>
|
||||
XML
|
||||
|
||||
describe "#initialize" do
|
||||
it "raises because it is not supported anymore" do
|
||||
expect {
|
||||
Entities::RelayableRetraction.new(data)
|
||||
}.to raise_error RuntimeError,
|
||||
"Sending RelayableRetraction is not supported anymore! Use Retraction instead!"
|
||||
end
|
||||
end
|
||||
|
||||
context "parse retraction" do
|
||||
it "parses the xml as a retraction" do
|
||||
expect(Entities::Retraction).to receive(:fetch_target).and_return(target_entity)
|
||||
retraction = Entities::RelayableRetraction.from_xml(Nokogiri::XML(xml).root)
|
||||
expect(retraction).to be_a(Entities::Retraction)
|
||||
expect(retraction.author).to eq(data[:author])
|
||||
expect(retraction.target_guid).to eq(data[:target_guid])
|
||||
expect(retraction.target_type).to eq(data[:target_type])
|
||||
expect(retraction.target).to eq(target_entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
describe Entities::SignedRetraction do
|
||||
let(:target) { Fabricate(:post, author: alice) }
|
||||
let(:target_entity) { Fabricate(:related_entity, author: alice.diaspora_id) }
|
||||
let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
|
||||
|
||||
let(:xml) { <<~XML }
|
||||
<signed_retraction>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<target_author_signature/>
|
||||
</signed_retraction>
|
||||
XML
|
||||
|
||||
describe "#initialize" do
|
||||
it "raises because it is not supported anymore" do
|
||||
expect {
|
||||
Entities::SignedRetraction.new(data)
|
||||
}.to raise_error RuntimeError,
|
||||
"Sending SignedRetraction is not supported anymore! Use Retraction instead!"
|
||||
end
|
||||
end
|
||||
|
||||
context "parse retraction" do
|
||||
it "parses the xml as a retraction" do
|
||||
expect(Entities::Retraction).to receive(:fetch_target).and_return(target_entity)
|
||||
retraction = Entities::SignedRetraction.from_xml(Nokogiri::XML(xml).root)
|
||||
expect(retraction).to be_a(Entities::Retraction)
|
||||
expect(retraction.author).to eq(data[:author])
|
||||
expect(retraction.target_guid).to eq(data[:target_guid])
|
||||
expect(retraction.target_type).to eq(data[:target_type])
|
||||
expect(retraction.target).to eq(target_entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue