diaspora_federation 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diaspora_federation.rb +103 -18
- data/lib/diaspora_federation/discovery/discovery.rb +1 -1
- data/lib/diaspora_federation/discovery/h_card.rb +4 -5
- data/lib/diaspora_federation/discovery/host_meta.rb +1 -1
- data/lib/diaspora_federation/discovery/web_finger.rb +8 -8
- data/lib/diaspora_federation/discovery/xrd_document.rb +6 -7
- data/lib/diaspora_federation/entities.rb +21 -10
- data/lib/diaspora_federation/entities/account_deletion.rb +7 -3
- data/lib/diaspora_federation/entities/comment.rb +13 -10
- data/lib/diaspora_federation/entities/contact.rb +29 -0
- data/lib/diaspora_federation/entities/conversation.rb +5 -6
- data/lib/diaspora_federation/entities/like.rb +10 -18
- data/lib/diaspora_federation/entities/message.rb +6 -12
- data/lib/diaspora_federation/entities/participation.rb +8 -16
- data/lib/diaspora_federation/entities/person.rb +6 -2
- data/lib/diaspora_federation/entities/photo.rb +3 -3
- data/lib/diaspora_federation/entities/poll_participation.rb +6 -12
- data/lib/diaspora_federation/entities/post.rb +37 -0
- data/lib/diaspora_federation/entities/profile.rb +7 -3
- data/lib/diaspora_federation/entities/relayable.rb +169 -65
- data/lib/diaspora_federation/entities/relayable_retraction.rb +33 -32
- data/lib/diaspora_federation/entities/request.rb +20 -6
- data/lib/diaspora_federation/entities/reshare.rb +5 -27
- data/lib/diaspora_federation/entities/retraction.rb +6 -6
- data/lib/diaspora_federation/entities/signed_retraction.rb +32 -26
- data/lib/diaspora_federation/entities/status_message.rb +2 -22
- data/lib/diaspora_federation/entity.rb +137 -38
- data/lib/diaspora_federation/federation.rb +9 -0
- data/lib/diaspora_federation/federation/fetcher.rb +26 -0
- data/lib/diaspora_federation/federation/receiver.rb +41 -0
- data/lib/diaspora_federation/federation/receiver/abstract_receiver.rb +35 -0
- data/lib/diaspora_federation/federation/receiver/exceptions.rb +13 -0
- data/lib/diaspora_federation/federation/receiver/private.rb +15 -0
- data/lib/diaspora_federation/federation/receiver/public.rb +9 -0
- data/lib/diaspora_federation/federation/sender.rb +33 -0
- data/lib/diaspora_federation/federation/sender/hydra_wrapper.rb +92 -0
- data/lib/diaspora_federation/{fetcher.rb → http_client.rb} +6 -6
- data/lib/diaspora_federation/properties_dsl.rb +51 -14
- data/lib/diaspora_federation/salmon.rb +2 -1
- data/lib/diaspora_federation/salmon/aes.rb +1 -1
- data/lib/diaspora_federation/salmon/encrypted_magic_envelope.rb +61 -0
- data/lib/diaspora_federation/salmon/encrypted_slap.rb +69 -50
- data/lib/diaspora_federation/salmon/exceptions.rb +8 -14
- data/lib/diaspora_federation/salmon/magic_envelope.rb +80 -39
- data/lib/diaspora_federation/salmon/slap.rb +20 -51
- data/lib/diaspora_federation/salmon/xml_payload.rb +5 -104
- data/lib/diaspora_federation/validators.rb +22 -16
- data/lib/diaspora_federation/validators/account_deletion_validator.rb +1 -1
- data/lib/diaspora_federation/validators/comment_validator.rb +0 -4
- data/lib/diaspora_federation/validators/contact_validator.rb +13 -0
- data/lib/diaspora_federation/validators/conversation_validator.rb +2 -2
- data/lib/diaspora_federation/validators/like_validator.rb +1 -3
- data/lib/diaspora_federation/validators/message_validator.rb +0 -4
- data/lib/diaspora_federation/validators/participation_validator.rb +1 -5
- data/lib/diaspora_federation/validators/person_validator.rb +1 -1
- data/lib/diaspora_federation/validators/photo_validator.rb +2 -2
- data/lib/diaspora_federation/validators/poll_participation_validator.rb +0 -4
- data/lib/diaspora_federation/validators/profile_validator.rb +1 -1
- data/lib/diaspora_federation/validators/relayable_retraction_validator.rb +1 -1
- data/lib/diaspora_federation/validators/relayable_validator.rb +2 -0
- data/lib/diaspora_federation/validators/request_validator.rb +3 -2
- data/lib/diaspora_federation/validators/reshare_validator.rb +3 -3
- data/lib/diaspora_federation/validators/retraction_validator.rb +2 -2
- data/lib/diaspora_federation/validators/rules/guid.rb +16 -7
- data/lib/diaspora_federation/validators/signed_retraction_validator.rb +1 -1
- data/lib/diaspora_federation/validators/status_message_validator.rb +2 -2
- data/lib/diaspora_federation/version.rb +1 -1
- metadata +20 -11
- data/lib/diaspora_federation/receiver.rb +0 -28
- data/lib/diaspora_federation/receiver/private.rb +0 -19
- data/lib/diaspora_federation/receiver/public.rb +0 -13
- data/lib/diaspora_federation/signing.rb +0 -56
@@ -21,49 +21,20 @@ module DiasporaFederation
|
|
21
21
|
# slap_xml = Slap.generate_xml(author_id, author_privkey, entity)
|
22
22
|
#
|
23
23
|
# @example Parsing a Salmon Slap
|
24
|
-
#
|
25
|
-
# author_pubkey = however_you_retrieve_the_authors_public_key(slap.author_id)
|
24
|
+
# entity = Slap.from_xml(slap_xml).payload
|
26
25
|
#
|
27
|
-
#
|
26
|
+
# @deprecated
|
28
27
|
class Slap
|
29
|
-
# the author of the slap
|
30
|
-
# @overload author_id
|
31
|
-
# @return [String] the author diaspora id
|
32
|
-
# @overload author_id=
|
33
|
-
# @param [String] the author diaspora id
|
34
|
-
attr_accessor :author_id
|
35
|
-
|
36
|
-
# the key and iv if it is an encrypted slap
|
37
|
-
# @param [Hash] value hash containing the key and iv
|
38
|
-
attr_writer :cipher_params
|
39
|
-
|
40
28
|
# Namespaces
|
41
|
-
NS = {d: Salmon::XMLNS, me: MagicEnvelope::XMLNS}
|
42
|
-
|
43
|
-
# Returns new instance of the Entity that is contained within the XML of
|
44
|
-
# this Slap.
|
45
|
-
#
|
46
|
-
# The first time this is called, a public key has to be specified to verify
|
47
|
-
# the Magic Envelope signature. On repeated calls, the key may be omitted.
|
48
|
-
#
|
49
|
-
# @see MagicEnvelope.unenvelop
|
50
|
-
#
|
51
|
-
# @param [OpenSSL::PKey::RSA] pubkey public key for validating the signature
|
52
|
-
# @return [Entity] entity instance from the XML
|
53
|
-
# @raise [ArgumentError] if the public key is of the wrong type
|
54
|
-
def entity(pubkey=nil)
|
55
|
-
return @entity unless @entity.nil?
|
56
|
-
|
57
|
-
raise ArgumentError unless pubkey.instance_of?(OpenSSL::PKey::RSA)
|
58
|
-
@entity = MagicEnvelope.unenvelop(@magic_envelope, pubkey, @cipher_params)
|
59
|
-
@entity
|
60
|
-
end
|
29
|
+
NS = {d: Salmon::XMLNS, me: MagicEnvelope::XMLNS}.freeze
|
61
30
|
|
62
31
|
# Parses an unencrypted Salmon XML string and returns a new instance of
|
63
|
-
# {
|
32
|
+
# {MagicEnvelope} with the XML data.
|
64
33
|
#
|
65
34
|
# @param [String] slap_xml Salmon XML
|
66
|
-
#
|
35
|
+
#
|
36
|
+
# @return [MagicEnvelope] magic envelope instance with payload and sender
|
37
|
+
#
|
67
38
|
# @raise [ArgumentError] if the argument is not a String
|
68
39
|
# @raise [MissingAuthor] if the +author_id+ element is missing from the XML
|
69
40
|
# @raise [MissingMagicEnvelope] if the +me:env+ element is missing from the XML
|
@@ -71,25 +42,23 @@ module DiasporaFederation
|
|
71
42
|
raise ArgumentError unless slap_xml.instance_of?(String)
|
72
43
|
doc = Nokogiri::XML::Document.parse(slap_xml)
|
73
44
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
slap.author_id = author_elem.content
|
45
|
+
author_elem = doc.at_xpath("d:diaspora/d:header/d:author_id", Slap::NS)
|
46
|
+
raise MissingAuthor if author_elem.nil? || author_elem.content.empty?
|
47
|
+
sender = author_elem.content
|
78
48
|
|
79
|
-
|
80
|
-
end
|
49
|
+
MagicEnvelope.unenvelop(magic_env_from_doc(doc), sender)
|
81
50
|
end
|
82
51
|
|
83
52
|
# Creates an unencrypted Salmon Slap and returns the XML string.
|
84
53
|
#
|
85
54
|
# @param [String] author_id Diaspora* handle of the author
|
86
|
-
# @param [OpenSSL::PKey::RSA]
|
55
|
+
# @param [OpenSSL::PKey::RSA] privkey sender private_key for signing the magic envelope
|
87
56
|
# @param [Entity] entity payload
|
88
57
|
# @return [String] Salmon XML string
|
89
58
|
# @raise [ArgumentError] if any of the arguments is not the correct type
|
90
|
-
def self.generate_xml(author_id,
|
59
|
+
def self.generate_xml(author_id, privkey, entity)
|
91
60
|
raise ArgumentError unless author_id.instance_of?(String) &&
|
92
|
-
|
61
|
+
privkey.instance_of?(OpenSSL::PKey::RSA) &&
|
93
62
|
entity.is_a?(Entity)
|
94
63
|
|
95
64
|
build_xml do |xml|
|
@@ -97,7 +66,7 @@ module DiasporaFederation
|
|
97
66
|
xml.author_id(author_id)
|
98
67
|
}
|
99
68
|
|
100
|
-
MagicEnvelope.new(
|
69
|
+
xml.parent << MagicEnvelope.new(entity, author_id).envelop(privkey)
|
101
70
|
end
|
102
71
|
end
|
103
72
|
|
@@ -107,22 +76,22 @@ module DiasporaFederation
|
|
107
76
|
# {http://www.rubydoc.info/gems/nokogiri/Nokogiri/XML/Builder Nokogiri::XML::Builder}
|
108
77
|
# @return [String] Slap XML
|
109
78
|
def self.build_xml
|
110
|
-
|
79
|
+
Nokogiri::XML::Builder.new(encoding: "UTF-8") {|xml|
|
111
80
|
xml.diaspora("xmlns" => Salmon::XMLNS, "xmlns:me" => MagicEnvelope::XMLNS) {
|
112
81
|
yield xml
|
113
82
|
}
|
114
|
-
|
115
|
-
builder.to_xml
|
83
|
+
}.to_xml
|
116
84
|
end
|
117
85
|
|
118
86
|
# Parses the magic envelop from the document.
|
119
87
|
#
|
120
88
|
# @param [Nokogiri::XML::Document] doc Salmon XML Document
|
121
|
-
def
|
122
|
-
|
89
|
+
def self.magic_env_from_doc(doc)
|
90
|
+
doc.at_xpath("d:diaspora/me:env", Slap::NS).tap do |env|
|
123
91
|
raise MissingMagicEnvelope if env.nil?
|
124
92
|
end
|
125
93
|
end
|
94
|
+
private_class_method :magic_env_from_doc
|
126
95
|
end
|
127
96
|
end
|
128
97
|
end
|
@@ -11,6 +11,7 @@ module DiasporaFederation
|
|
11
11
|
# </XML>
|
12
12
|
#
|
13
13
|
# (The +post+ element is there for historic reasons...)
|
14
|
+
# @deprecated
|
14
15
|
module XmlPayload
|
15
16
|
# Encapsulates an Entity inside the wrapping xml structure
|
16
17
|
# and returns the XML Object.
|
@@ -39,122 +40,22 @@ module DiasporaFederation
|
|
39
40
|
# @return [Entity] re-constructed Entity instance
|
40
41
|
# @raise [ArgumentError] if the argument is not an
|
41
42
|
# {http://www.rubydoc.info/gems/nokogiri/Nokogiri/XML/Element Nokogiri::XML::Element}
|
42
|
-
# @raise [InvalidStructure] if the XML doesn't look like the wrapper XML
|
43
43
|
# @raise [UnknownEntity] if the class for the entity contained inside the
|
44
44
|
# XML can't be found
|
45
45
|
def self.unpack(xml)
|
46
46
|
raise ArgumentError, "only Nokogiri::XML::Element allowed" unless xml.instance_of?(Nokogiri::XML::Element)
|
47
|
-
raise Salmon::InvalidStructure unless wrap_valid?(xml)
|
48
47
|
|
49
|
-
data = xml.at_xpath("post/*[1]")
|
50
|
-
klass_name = entity_class_name(data.name)
|
51
|
-
raise Salmon::UnknownEntity, "'#{klass_name}' not found" unless Entities.const_defined?(klass_name)
|
48
|
+
data = xml_wrapped?(xml) ? xml.at_xpath("post/*[1]") : xml
|
52
49
|
|
53
|
-
|
54
|
-
populate_entity(klass, data)
|
50
|
+
Entity.entity_class(data.name).from_xml(data)
|
55
51
|
end
|
56
52
|
|
57
|
-
private
|
58
|
-
|
59
53
|
# @param [Nokogiri::XML::Element] element
|
60
|
-
def self.
|
54
|
+
def self.xml_wrapped?(element)
|
61
55
|
(element.name == "XML" && !element.at_xpath("post").nil? &&
|
62
56
|
!element.at_xpath("post").children.empty?)
|
63
57
|
end
|
64
|
-
private_class_method :
|
65
|
-
|
66
|
-
# Transform the given String from the lowercase underscored version to a
|
67
|
-
# camelized variant, used later for getting the Class constant.
|
68
|
-
#
|
69
|
-
# @param [String] term "snake_case" class name
|
70
|
-
# @return [String] "CamelCase" class name
|
71
|
-
def self.entity_class_name(term)
|
72
|
-
term.to_s.tap do |string|
|
73
|
-
raise Salmon::InvalidEntityName, "'#{string}' is invalid" unless string =~ /^[a-z]*(_[a-z]*)*$/
|
74
|
-
string.sub!(/^[a-z]/, &:upcase)
|
75
|
-
string.gsub!(/_([a-z])/) { Regexp.last_match[1].upcase }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
private_class_method :entity_class_name
|
79
|
-
|
80
|
-
# Construct a new instance of the given Entity and populate the properties
|
81
|
-
# with the attributes found in the XML.
|
82
|
-
# Works recursively on nested Entities and Arrays thereof.
|
83
|
-
#
|
84
|
-
# @param [Class] klass entity class
|
85
|
-
# @param [Nokogiri::XML::Element] root_node xml nodes
|
86
|
-
# @return [Entity] instance
|
87
|
-
def self.populate_entity(klass, root_node)
|
88
|
-
# Use all known properties to build the Entity. All other elements are respected
|
89
|
-
# and attached to resulted hash as string. It is intended to build a hash
|
90
|
-
# invariable of an Entity definition, in order to support receiving objects
|
91
|
-
# from the future versions of Diaspora, where new elements may have been added.
|
92
|
-
data = Hash[root_node.element_children.map { |child|
|
93
|
-
xml_name = child.name
|
94
|
-
property = klass.class_props.find {|prop| prop[:xml_name].to_s == xml_name }
|
95
|
-
if property
|
96
|
-
parse_element_from_node(property[:name], property[:type], xml_name, root_node)
|
97
|
-
else
|
98
|
-
[xml_name, child.text]
|
99
|
-
end
|
100
|
-
}]
|
101
|
-
|
102
|
-
if klass.included_modules.include?(Entities::Relayable)
|
103
|
-
Entities::Relayable.verify_signatures(data, klass)
|
104
|
-
end
|
105
|
-
|
106
|
-
klass.new(data)
|
107
|
-
end
|
108
|
-
private_class_method :populate_entity
|
109
|
-
|
110
|
-
# @param [Symbol] name property name
|
111
|
-
# @param [Class] type target type to parse
|
112
|
-
# @param [String] xml_name xml tag to parse
|
113
|
-
# @param [Nokogiri::XML::Element] node XML node to parse
|
114
|
-
# @return [Array<Symbol, Object>] parsed data
|
115
|
-
def self.parse_element_from_node(name, type, xml_name, node)
|
116
|
-
if type == String
|
117
|
-
[name, parse_string_from_node(xml_name, node)]
|
118
|
-
elsif type.instance_of?(Array)
|
119
|
-
[name, parse_array_from_node(type, node)]
|
120
|
-
elsif type.ancestors.include?(Entity)
|
121
|
-
[name, parse_entity_from_node(type, node)]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
private_class_method :parse_element_from_node
|
125
|
-
|
126
|
-
# create simple entry in data hash
|
127
|
-
#
|
128
|
-
# @param [String] name xml tag to parse
|
129
|
-
# @param [Nokogiri::XML::Element] root_node XML root_node to parse
|
130
|
-
# @return [String] data
|
131
|
-
def self.parse_string_from_node(name, root_node)
|
132
|
-
node = root_node.xpath(name.to_s)
|
133
|
-
node.first.text if node.any?
|
134
|
-
end
|
135
|
-
private_class_method :parse_string_from_node
|
136
|
-
|
137
|
-
# create an entry in the data hash for the nested entity
|
138
|
-
#
|
139
|
-
# @param [Class] type target type to parse
|
140
|
-
# @param [Nokogiri::XML::Element] root_node XML node to parse
|
141
|
-
# @return [Entity] parsed child entity
|
142
|
-
def self.parse_entity_from_node(type, root_node)
|
143
|
-
node = root_node.xpath(type.entity_name)
|
144
|
-
populate_entity(type, node.first) if node.any?
|
145
|
-
end
|
146
|
-
private_class_method :parse_entity_from_node
|
147
|
-
|
148
|
-
# collect all nested children of that type and create an array in the data hash
|
149
|
-
#
|
150
|
-
# @param [Array<Class>] type target type to parse
|
151
|
-
# @param [Nokogiri::XML::Element] root_node XML node to parse
|
152
|
-
# @return [Array<Entity>] array with parsed child entities
|
153
|
-
def self.parse_array_from_node(type, root_node)
|
154
|
-
node = root_node.xpath(type.first.entity_name)
|
155
|
-
node.map {|child| populate_entity(type.first, child) }
|
156
|
-
end
|
157
|
-
private_class_method :parse_array_from_node
|
58
|
+
private_class_method :xml_wrapped?
|
158
59
|
end
|
159
60
|
end
|
160
61
|
end
|
@@ -19,11 +19,11 @@ end
|
|
19
19
|
require "diaspora_federation/validators/rules/birthday"
|
20
20
|
require "diaspora_federation/validators/rules/boolean"
|
21
21
|
require "diaspora_federation/validators/rules/diaspora_id"
|
22
|
+
require "diaspora_federation/validators/rules/diaspora_id_count"
|
22
23
|
require "diaspora_federation/validators/rules/guid"
|
23
24
|
require "diaspora_federation/validators/rules/not_nil"
|
24
25
|
require "diaspora_federation/validators/rules/public_key"
|
25
26
|
require "diaspora_federation/validators/rules/tag_count"
|
26
|
-
require "diaspora_federation/validators/rules/diaspora_id_count"
|
27
27
|
|
28
28
|
module DiasporaFederation
|
29
29
|
# Validators to perform basic sanity-checks on {DiasporaFederation::Entities federation entities}.
|
@@ -34,25 +34,31 @@ module DiasporaFederation
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
# abstract types
|
37
38
|
require "diaspora_federation/validators/relayable_validator"
|
39
|
+
|
40
|
+
# types
|
41
|
+
require "diaspora_federation/validators/account_deletion_validator"
|
42
|
+
require "diaspora_federation/validators/comment_validator"
|
43
|
+
require "diaspora_federation/validators/contact_validator"
|
44
|
+
require "diaspora_federation/validators/conversation_validator"
|
38
45
|
require "diaspora_federation/validators/h_card_validator"
|
39
|
-
require "diaspora_federation/validators/person_validator"
|
40
|
-
require "diaspora_federation/validators/profile_validator"
|
41
|
-
require "diaspora_federation/validators/web_finger_validator"
|
42
|
-
require "diaspora_federation/validators/request_validator"
|
43
|
-
require "diaspora_federation/validators/photo_validator"
|
44
|
-
require "diaspora_federation/validators/location_validator"
|
45
|
-
require "diaspora_federation/validators/status_message_validator"
|
46
|
-
require "diaspora_federation/validators/participation_validator"
|
47
46
|
require "diaspora_federation/validators/like_validator"
|
48
|
-
require "diaspora_federation/validators/
|
49
|
-
require "diaspora_federation/validators/account_deletion_validator"
|
47
|
+
require "diaspora_federation/validators/location_validator"
|
50
48
|
require "diaspora_federation/validators/message_validator"
|
51
|
-
require "diaspora_federation/validators/
|
52
|
-
require "diaspora_federation/validators/
|
49
|
+
require "diaspora_federation/validators/participation_validator"
|
50
|
+
require "diaspora_federation/validators/person_validator"
|
51
|
+
require "diaspora_federation/validators/photo_validator"
|
52
|
+
require "diaspora_federation/validators/poll_answer_validator"
|
53
|
+
require "diaspora_federation/validators/poll_participation_validator"
|
54
|
+
require "diaspora_federation/validators/poll_validator"
|
55
|
+
require "diaspora_federation/validators/profile_validator"
|
53
56
|
require "diaspora_federation/validators/reshare_validator"
|
54
57
|
require "diaspora_federation/validators/retraction_validator"
|
58
|
+
require "diaspora_federation/validators/status_message_validator"
|
59
|
+
require "diaspora_federation/validators/web_finger_validator"
|
60
|
+
|
61
|
+
# deprecated
|
62
|
+
require "diaspora_federation/validators/relayable_retraction_validator"
|
63
|
+
require "diaspora_federation/validators/request_validator"
|
55
64
|
require "diaspora_federation/validators/signed_retraction_validator"
|
56
|
-
require "diaspora_federation/validators/poll_answer_validator"
|
57
|
-
require "diaspora_federation/validators/poll_validator"
|
58
|
-
require "diaspora_federation/validators/poll_participation_validator"
|
@@ -4,14 +4,10 @@ module DiasporaFederation
|
|
4
4
|
class CommentValidator < Validation::Validator
|
5
5
|
include Validation
|
6
6
|
|
7
|
-
rule :guid, :guid
|
8
|
-
|
9
7
|
include RelayableValidator
|
10
8
|
|
11
9
|
rule :text, [:not_empty,
|
12
10
|
length: {maximum: 65_535}]
|
13
|
-
|
14
|
-
rule :diaspora_id, %i(not_empty diaspora_id)
|
15
11
|
end
|
16
12
|
end
|
17
13
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module DiasporaFederation
|
2
|
+
module Validators
|
3
|
+
# This validates a {Entities::Contact}
|
4
|
+
class ContactValidator < Validation::Validator
|
5
|
+
include Validation
|
6
|
+
|
7
|
+
rule :author, %i(not_empty diaspora_id)
|
8
|
+
rule :recipient, %i(not_empty diaspora_id)
|
9
|
+
rule :following, :boolean
|
10
|
+
rule :sharing, :boolean
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -6,9 +6,9 @@ module DiasporaFederation
|
|
6
6
|
|
7
7
|
rule :guid, :guid
|
8
8
|
|
9
|
-
rule :
|
9
|
+
rule :author, %i(not_empty diaspora_id)
|
10
10
|
|
11
|
-
rule :
|
11
|
+
rule :participants, diaspora_id_count: {maximum: 20}
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -4,11 +4,9 @@ module DiasporaFederation
|
|
4
4
|
class LikeValidator < Validation::Validator
|
5
5
|
include Validation
|
6
6
|
|
7
|
-
rule :guid, :guid
|
8
|
-
|
9
7
|
include RelayableValidator
|
10
8
|
|
11
|
-
rule :
|
9
|
+
rule :parent_type, [:not_empty, regular_expression: {regex: /\A(Post|Comment)\z/}]
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -4,13 +4,9 @@ module DiasporaFederation
|
|
4
4
|
class ParticipationValidator < Validation::Validator
|
5
5
|
include Validation
|
6
6
|
|
7
|
-
rule :guid, :guid
|
8
|
-
|
9
|
-
rule :target_type, :not_empty
|
10
|
-
|
11
7
|
include RelayableValidator
|
12
8
|
|
13
|
-
rule :
|
9
|
+
rule :parent_type, [:not_empty, regular_expression: {regex: /\APost\z/}]
|
14
10
|
end
|
15
11
|
end
|
16
12
|
end
|
@@ -6,7 +6,7 @@ module DiasporaFederation
|
|
6
6
|
|
7
7
|
rule :guid, :guid
|
8
8
|
|
9
|
-
rule :
|
9
|
+
rule :author, %i(not_empty diaspora_id)
|
10
10
|
|
11
11
|
rule :public, :boolean
|
12
12
|
|
@@ -14,7 +14,7 @@ module DiasporaFederation
|
|
14
14
|
|
15
15
|
rule :remote_photo_name, :not_empty
|
16
16
|
|
17
|
-
rule :status_message_guid, :
|
17
|
+
rule :status_message_guid, guid: {nilable: true}
|
18
18
|
|
19
19
|
rule :height, :numeric
|
20
20
|
|
@@ -4,12 +4,8 @@ module DiasporaFederation
|
|
4
4
|
class PollParticipationValidator < Validation::Validator
|
5
5
|
include Validation
|
6
6
|
|
7
|
-
rule :guid, :guid
|
8
|
-
|
9
7
|
include RelayableValidator
|
10
8
|
|
11
|
-
rule :diaspora_id, %i(not_empty diaspora_id)
|
12
|
-
|
13
9
|
rule :poll_answer_guid, :guid
|
14
10
|
end
|
15
11
|
end
|