diff --git a/lib/diaspora_federation/entities/reshare.rb b/lib/diaspora_federation/entities/reshare.rb
index 96ae593..d20cd51 100644
--- a/lib/diaspora_federation/entities/reshare.rb
+++ b/lib/diaspora_federation/entities/reshare.rb
@@ -4,7 +4,22 @@ module DiasporaFederation
#
# @see Validators::ReshareValidator
class Reshare < Entity
- include Post
+ # @!attribute [r] author
+ # The diaspora* ID of the person who reshares the post
+ # @see Person#author
+ # @return [String] diaspora* ID
+ property :author, :string, xml_name: :diaspora_handle
+
+ # @!attribute [r] guid
+ # A random string of at least 16 chars
+ # @see Validation::Rule::Guid
+ # @return [String] status message guid
+ property :guid, :string
+
+ # @!attribute [r] created_at
+ # Post entity creation time
+ # @return [Time] creation time
+ property :created_at, :timestamp, default: -> { Time.now.utc }
# @!attribute [r] root_author
# The diaspora* ID of the person who posted the original post
@@ -18,11 +33,6 @@ module DiasporaFederation
# @return [String] root guid
property :root_guid, :string, optional: true
- # @!attribute [r] public
- # Has no meaning at the moment
- # @return [Boolean] public
- property :public, :boolean, optional: true, default: true # always true? (we only reshare public posts)
-
# @return [String] string representation of this object
def to_s
"#{super}:#{root_guid}"
@@ -30,6 +40,11 @@ module DiasporaFederation
# Fetch and receive root post from remote, if not available locally
# and validates if it's from the correct author
+ # TODO: after reshares are only used to increase the reach of a post (and
+ # legacy reshares with own interactions are migrated to the new form),
+ # root_author and root_guid aren't allowed to be empty anymore, so a
+ # not_nil check should be added to the validator and the first few lines
+ # here can be removed.
def validate_root
return if root_author.nil? && root_guid.nil?
diff --git a/lib/diaspora_federation/schemas/federation_entities.json b/lib/diaspora_federation/schemas/federation_entities.json
index b9a8012..b30af83 100644
--- a/lib/diaspora_federation/schemas/federation_entities.json
+++ b/lib/diaspora_federation/schemas/federation_entities.json
@@ -215,28 +215,26 @@
},
"reshare": {
- "allOf": [
- {"$ref": "#/definitions/post"},
- {
+ "type": "object",
+ "properties": {
+ "entity_type": {
+ "type": "string",
+ "pattern": "^reshare$"
+ },
+
+ "entity_data": {
"type": "object",
"properties": {
- "entity_type": {
- "type": "string",
- "pattern": "^reshare$"
- },
-
- "entity_data": {
- "type": "object",
- "properties": {
- "root_author": {"type": "string"},
- "root_guid": {"$ref": "#/definitions/guid"}
- },
-
- "required": ["root_author", "root_guid"]
- }
- }
- }
- ]
+ "author": { "type": "string" },
+ "guid": { "$ref": "#/definitions/guid" },
+ "created_at": { "type": "string" },
+ "root_author": {"type": "string"},
+ "root_guid": {"$ref": "#/definitions/guid"}
+ },
+ "required": ["author", "guid", "created_at", "root_author", "root_guid"]
+ },
+ "required": ["entity_type", "entity_data"]
+ }
},
"profile": {
diff --git a/lib/diaspora_federation/test/factories.rb b/lib/diaspora_federation/test/factories.rb
index dce4e6e..9c4d83f 100644
--- a/lib/diaspora_federation/test/factories.rb
+++ b/lib/diaspora_federation/test/factories.rb
@@ -150,9 +150,7 @@ module DiasporaFederation
root_guid { Fabricate.sequence(:guid) }
guid { Fabricate.sequence(:guid) }
author { Fabricate.sequence(:diaspora_id) }
- public true
created_at { Time.now.utc }
- provider_display_name { "the testsuite" }
end
Fabricator(:retraction_entity, class_name: DiasporaFederation::Entities::Retraction) do
diff --git a/lib/diaspora_federation/validators/reshare_validator.rb b/lib/diaspora_federation/validators/reshare_validator.rb
index db8858d..ab5a0d8 100644
--- a/lib/diaspora_federation/validators/reshare_validator.rb
+++ b/lib/diaspora_federation/validators/reshare_validator.rb
@@ -11,8 +11,6 @@ module DiasporaFederation
rule :author, %i[not_empty diaspora_id]
rule :guid, :guid
-
- rule :public, :boolean
end
end
end
diff --git a/spec/lib/diaspora_federation/entities/reshare_spec.rb b/spec/lib/diaspora_federation/entities/reshare_spec.rb
index 2ba066b..7a15a85 100644
--- a/spec/lib/diaspora_federation/entities/reshare_spec.rb
+++ b/spec/lib/diaspora_federation/entities/reshare_spec.rb
@@ -8,10 +8,8 @@ module DiasporaFederation
#{data[:author]}
#{data[:guid]}
#{data[:created_at].utc.iso8601}
- #{data[:provider_display_name]}
#{data[:root_author]}
#{data[:root_guid]}
- #{data[:public]}
XML
@@ -22,10 +20,8 @@ XML
"author": "#{data[:author]}",
"guid": "#{data[:guid]}",
"created_at": "#{data[:created_at].utc.iso8601}",
- "provider_display_name": "#{data[:provider_display_name]}",
"root_author": "#{data[:root_author]}",
- "root_guid": "#{data[:root_guid]}",
- "public": #{data[:public]}
+ "root_guid": "#{data[:root_guid]}"
}
}
JSON
@@ -38,24 +34,6 @@ JSON
it_behaves_like "a JSON Entity"
- context "default values" do
- it "uses default values" do
- minimal_xml = <<-XML
-
- #{data[:author]}
- #{data[:guid]}
- #{data[:created_at]}
- #{data[:root_author]}
- #{data[:root_guid]}
-
-XML
-
- parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML(minimal_xml).root)
- expect(parsed_instance.public).to be_truthy
- expect(parsed_instance.provider_display_name).to be_nil
- end
- end
-
context "parse xml" do
describe "#validate_root" do
it "fetches the root post if it is not available already" do
diff --git a/spec/lib/diaspora_federation/validators/reshare_validator_spec.rb b/spec/lib/diaspora_federation/validators/reshare_validator_spec.rb
index e78905d..d163472 100644
--- a/spec/lib/diaspora_federation/validators/reshare_validator_spec.rb
+++ b/spec/lib/diaspora_federation/validators/reshare_validator_spec.rb
@@ -28,9 +28,5 @@ module DiasporaFederation
let(:mandatory) { false }
end
end
-
- it_behaves_like "a boolean validator" do
- let(:property) { :public }
- end
end
end