diaspora_federation 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +28 -0
  3. data/README.md +2 -1
  4. data/lib/diaspora_federation.rb +14 -14
  5. data/lib/diaspora_federation/callbacks.rb +4 -4
  6. data/lib/diaspora_federation/discovery.rb +1 -1
  7. data/lib/diaspora_federation/discovery/discovery.rb +8 -8
  8. data/lib/diaspora_federation/discovery/h_card.rb +11 -12
  9. data/lib/diaspora_federation/discovery/host_meta.rb +2 -2
  10. data/lib/diaspora_federation/discovery/web_finger.rb +10 -13
  11. data/lib/diaspora_federation/discovery/xrd_document.rb +1 -1
  12. data/lib/diaspora_federation/entities.rb +2 -2
  13. data/lib/diaspora_federation/entities/account_deletion.rb +4 -4
  14. data/lib/diaspora_federation/entities/comment.rb +3 -3
  15. data/lib/diaspora_federation/entities/contact.rb +4 -4
  16. data/lib/diaspora_federation/entities/conversation.rb +13 -13
  17. data/lib/diaspora_federation/entities/like.rb +5 -5
  18. data/lib/diaspora_federation/entities/location.rb +1 -1
  19. data/lib/diaspora_federation/entities/message.rb +5 -5
  20. data/lib/diaspora_federation/entities/participation.rb +6 -6
  21. data/lib/diaspora_federation/entities/person.rb +6 -6
  22. data/lib/diaspora_federation/entities/photo.rb +10 -10
  23. data/lib/diaspora_federation/entities/poll.rb +3 -3
  24. data/lib/diaspora_federation/entities/poll_answer.rb +2 -2
  25. data/lib/diaspora_federation/entities/poll_participation.rb +3 -3
  26. data/lib/diaspora_federation/entities/post.rb +7 -7
  27. data/lib/diaspora_federation/entities/profile.rb +6 -6
  28. data/lib/diaspora_federation/entities/related_entity.rb +4 -4
  29. data/lib/diaspora_federation/entities/relayable.rb +32 -24
  30. data/lib/diaspora_federation/entities/relayable_retraction.rb +17 -17
  31. data/lib/diaspora_federation/entities/request.rb +5 -5
  32. data/lib/diaspora_federation/entities/reshare.rb +7 -7
  33. data/lib/diaspora_federation/entities/retraction.rb +6 -6
  34. data/lib/diaspora_federation/entities/signed_retraction.rb +8 -8
  35. data/lib/diaspora_federation/entities/status_message.rb +8 -8
  36. data/lib/diaspora_federation/entity.rb +7 -7
  37. data/lib/diaspora_federation/federation/fetcher.rb +3 -3
  38. data/lib/diaspora_federation/federation/receiver.rb +3 -3
  39. data/lib/diaspora_federation/federation/receiver/abstract_receiver.rb +3 -3
  40. data/lib/diaspora_federation/federation/receiver/private.rb +1 -1
  41. data/lib/diaspora_federation/federation/receiver/public.rb +1 -1
  42. data/lib/diaspora_federation/federation/sender/hydra_wrapper.rb +7 -6
  43. data/lib/diaspora_federation/http_client.rb +2 -2
  44. data/lib/diaspora_federation/logging.rb +7 -7
  45. data/lib/diaspora_federation/properties_dsl.rb +3 -3
  46. data/lib/diaspora_federation/salmon.rb +1 -1
  47. data/lib/diaspora_federation/salmon/aes.rb +4 -4
  48. data/lib/diaspora_federation/salmon/encrypted_slap.rb +9 -9
  49. data/lib/diaspora_federation/salmon/magic_envelope.rb +16 -16
  50. data/lib/diaspora_federation/salmon/slap.rb +2 -2
  51. data/lib/diaspora_federation/validators.rb +1 -1
  52. data/lib/diaspora_federation/validators/account_deletion_validator.rb +1 -1
  53. data/lib/diaspora_federation/validators/comment_validator.rb +1 -1
  54. data/lib/diaspora_federation/validators/contact_validator.rb +1 -1
  55. data/lib/diaspora_federation/validators/conversation_validator.rb +4 -4
  56. data/lib/diaspora_federation/validators/h_card_validator.rb +2 -2
  57. data/lib/diaspora_federation/validators/like_validator.rb +1 -1
  58. data/lib/diaspora_federation/validators/location_validator.rb +1 -1
  59. data/lib/diaspora_federation/validators/message_validator.rb +4 -1
  60. data/lib/diaspora_federation/validators/participation_validator.rb +1 -1
  61. data/lib/diaspora_federation/validators/person_validator.rb +1 -1
  62. data/lib/diaspora_federation/validators/photo_validator.rb +3 -1
  63. data/lib/diaspora_federation/validators/poll_answer_validator.rb +1 -1
  64. data/lib/diaspora_federation/validators/poll_participation_validator.rb +1 -1
  65. data/lib/diaspora_federation/validators/poll_validator.rb +1 -1
  66. data/lib/diaspora_federation/validators/profile_validator.rb +3 -3
  67. data/lib/diaspora_federation/validators/related_entity_validator.rb +1 -1
  68. data/lib/diaspora_federation/validators/relayable_retraction_validator.rb +2 -2
  69. data/lib/diaspora_federation/validators/relayable_validator.rb +2 -2
  70. data/lib/diaspora_federation/validators/request_validator.rb +2 -2
  71. data/lib/diaspora_federation/validators/reshare_validator.rb +1 -1
  72. data/lib/diaspora_federation/validators/retraction_validator.rb +1 -1
  73. data/lib/diaspora_federation/validators/rules/birthday.rb +2 -2
  74. data/lib/diaspora_federation/validators/rules/boolean.rb +1 -1
  75. data/lib/diaspora_federation/validators/rules/diaspora_id.rb +5 -5
  76. data/lib/diaspora_federation/validators/rules/diaspora_id_count.rb +3 -3
  77. data/lib/diaspora_federation/validators/rules/guid.rb +4 -4
  78. data/lib/diaspora_federation/validators/rules/not_nil.rb +1 -1
  79. data/lib/diaspora_federation/validators/rules/public_key.rb +1 -1
  80. data/lib/diaspora_federation/validators/rules/tag_count.rb +2 -2
  81. data/lib/diaspora_federation/validators/signed_retraction_validator.rb +2 -2
  82. data/lib/diaspora_federation/validators/status_message_validator.rb +3 -1
  83. data/lib/diaspora_federation/validators/web_finger_validator.rb +3 -3
  84. data/lib/diaspora_federation/version.rb +1 -1
  85. metadata +3 -2
@@ -1,17 +1,17 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity is sent when account was deleted on a remote pod
3
+ # This entity is sent when an account was deleted on a remote pod.
4
4
  #
5
5
  # @see Validators::AccountDeletionValidator
6
6
  class AccountDeletion < Entity
7
7
  # @!attribute [r] author
8
- # The diaspora ID of the deleted account
8
+ # The diaspora* ID of the deleted account
9
9
  # @see Person#author
10
- # @return [String] diaspora ID
10
+ # @return [String] diaspora* ID
11
11
  # @!attribute [r] diaspora_id
12
12
  # Alias for author
13
13
  # @see AccountDeletion#author
14
- # @return [String] diaspora ID
14
+ # @return [String] diaspora* ID
15
15
  property :author, alias: :diaspora_id, xml_name: :diaspora_handle
16
16
 
17
17
  # @return [String] string representation of this object
@@ -1,10 +1,10 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a comment to some kind of post (e.g. status message)
3
+ # This entity represents a comment to some kind of post (e.g. status message).
4
4
  #
5
5
  # @see Validators::CommentValidator
6
6
  class Comment < Entity
7
- # old signature order
7
+ # Old signature order
8
8
  # @deprecated
9
9
  LEGACY_SIGNATURE_ORDER = %i(guid parent_guid text author).freeze
10
10
 
@@ -18,7 +18,7 @@ module DiasporaFederation
18
18
  property :text
19
19
 
20
20
  # @!attribute [r] created_at
21
- # comment entity creation time
21
+ # Comment entity creation time
22
22
  # @return [Time] creation time
23
23
  property :created_at, default: -> { Time.now.utc }
24
24
  end
@@ -1,18 +1,18 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a contact with another person. A user issues it
4
- # when he starts sharing/following with another user.
3
+ # This entity represents a contact with another person. A user issues it
4
+ # when they start sharing/following with another user.
5
5
  #
6
6
  # @see Validators::ContactValidator
7
7
  class Contact < Entity
8
8
  # @!attribute [r] author
9
- # The diaspora ID of the person who shares his profile
9
+ # The diaspora* ID of the person who shares their profile
10
10
  # @see Person#author
11
11
  # @return [String] sender ID
12
12
  property :author
13
13
 
14
14
  # @!attribute [r] recipient
15
- # The diaspora ID of the person who will be shared with
15
+ # The diaspora* ID of the person who will be shared with
16
16
  # @see Validation::Rule::DiasporaId
17
17
  # @return [String] recipient ID
18
18
  property :recipient
@@ -1,11 +1,17 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a private conversation between users
3
+ # This entity represents a private conversation between users.
4
4
  #
5
5
  # @see Validators::ConversationValidator
6
6
  class Conversation < Entity
7
+ # @!attribute [r] author
8
+ # The diaspora* ID of the person initiated the conversation
9
+ # @see Person#author
10
+ # @return [String] diaspora* ID
11
+ property :author, xml_name: :diaspora_handle
12
+
7
13
  # @!attribute [r] guid
8
- # a random string of at least 16 chars.
14
+ # A random string of at least 16 chars
9
15
  # @see Validation::Rule::Guid
10
16
  # @return [String] conversation guid
11
17
  property :guid
@@ -18,21 +24,15 @@ module DiasporaFederation
18
24
  # @return [Time] Conversation creation time
19
25
  property :created_at, default: -> { Time.now.utc }
20
26
 
27
+ # @!attribute [r] participants
28
+ # The diaspora* IDs of the persons participating the conversation separated by ";"
29
+ # @return [String] participants diaspora* IDs
30
+ property :participants, xml_name: :participant_handles
31
+
21
32
  # @!attribute [r] messages
22
33
  # @return [[Entities::Message]] Messages of this conversation
23
34
  entity :messages, [Entities::Message], default: []
24
35
 
25
- # @!attribute [r] author
26
- # The diaspora ID of the person initiated the conversation.
27
- # @see Person#author
28
- # @return [String] diaspora ID
29
- property :author, xml_name: :diaspora_handle
30
-
31
- # @!attribute [r] participants
32
- # The diaspora IDs of the persons participating the conversation separated by ";".
33
- # @return [String] participants diaspora IDs
34
- property :participants, xml_name: :participant_handles
35
-
36
36
  private
37
37
 
38
38
  def validate
@@ -1,10 +1,10 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a like to some kind of post (e.g. status message)
3
+ # This entity represents a like to some kind of post (e.g. status message).
4
4
  #
5
5
  # @see Validators::LikeValidator
6
6
  class Like < Entity
7
- # old signature order
7
+ # Old signature order
8
8
  # @deprecated
9
9
  LEGACY_SIGNATURE_ORDER = %i(positive guid parent_type parent_guid author).freeze
10
10
 
@@ -12,14 +12,14 @@ module DiasporaFederation
12
12
 
13
13
  # @!attribute [r] positive
14
14
  # If +true+ set a like, if +false+, set a dislike (dislikes are currently not
15
- # implemented in the Diaspora frontend).
15
+ # implemented in the diaspora* frontend).
16
16
  # @return [Boolean] is it a like or a dislike
17
17
  property :positive
18
18
 
19
19
  # @!attribute [r] parent_type
20
- # A string describing the type of the parent.
20
+ # A string describing the type of the parent
21
21
  # Can be "Post" or "Comment" (Comments are currently not implemented in the
22
- # Diaspora Frontend).
22
+ # diaspora* frontend).
23
23
  # @return [String] parent type
24
24
  property :parent_type, xml_name: :target_type
25
25
  end
@@ -1,6 +1,6 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity is used to specify a location data and used embedded in a status message
3
+ # This entity is used to specify location data and used embedded in a status message.
4
4
  #
5
5
  # @see Validators::LocationValidator
6
6
  class Location < Entity
@@ -1,27 +1,27 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a private message exchanged in private conversation
3
+ # This entity represents a private message exchanged in private conversation.
4
4
  #
5
5
  # @see Validators::MessageValidator
6
6
  class Message < Entity
7
- # old signature order
7
+ # Old signature order
8
8
  # @deprecated
9
9
  LEGACY_SIGNATURE_ORDER = %i(guid parent_guid text created_at author conversation_guid).freeze
10
10
 
11
11
  include Relayable
12
12
 
13
13
  # @!attribute [r] text
14
- # text of the message composed by a user
14
+ # Text of the message composed by a user
15
15
  # @return [String] text
16
16
  property :text
17
17
 
18
18
  # @!attribute [r] created_at
19
- # message creation time
19
+ # Message creation time
20
20
  # @return [Time] creation time
21
21
  property :created_at, default: -> { Time.now.utc }
22
22
 
23
23
  # @!attribute [r] conversation_guid
24
- # guid of a conversation this message belongs to
24
+ # Guid of a conversation this message belongs to
25
25
  # @see Conversation#guid
26
26
  # @return [String] conversation guid
27
27
  property :conversation_guid
@@ -1,28 +1,28 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # participation is sent to subscribe a user on updates for some post
3
+ # Participation is sent to subscribe a user on updates for some post.
4
4
  #
5
5
  # @see Validators::Participation
6
6
  class Participation < Entity
7
- # old signature order
7
+ # Old signature order
8
8
  # @deprecated
9
9
  LEGACY_SIGNATURE_ORDER = %i(guid parent_type parent_guid author).freeze
10
10
 
11
11
  include Relayable
12
12
 
13
13
  # @!attribute [r] parent_type
14
- # a string describing a type of the target to subscribe on.
15
- # currently only "Post" is supported.
14
+ # A string describing a type of the target to subscribe on
15
+ # Currently only "Post" is supported.
16
16
  # @return [String] parent type
17
17
  property :parent_type, xml_name: :target_type
18
18
 
19
- # It is only valid to receive a {Participation} from the author itself.
19
+ # It is only valid to receive a {Participation} from the author themself.
20
20
  # @deprecated remove after {Participation} doesn't include {Relayable} anymore
21
21
  def sender_valid?(sender)
22
22
  sender == author
23
23
  end
24
24
 
25
- # validates that the parent exists and the parent author is local
25
+ # Validates that the parent exists and the parent author is local
26
26
  def validate_parent
27
27
  parent = DiasporaFederation.callbacks.trigger(:fetch_related_entity, parent_type, parent_guid)
28
28
  raise ParentNotLocal, "obj=#{self}" unless parent && parent.local
@@ -1,6 +1,6 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity contains the base data of a person
3
+ # This entity contains the base data of a person.
4
4
  #
5
5
  # @see Validators::PersonValidator
6
6
  class Person < Entity
@@ -12,13 +12,13 @@ module DiasporaFederation
12
12
  property :guid
13
13
 
14
14
  # @!attribute [r] author
15
- # The diaspora ID of the person
15
+ # The diaspora* ID of the person
16
16
  # @see Validation::Rule::DiasporaId
17
- # @return [String] diaspora ID
17
+ # @return [String] diaspora* ID
18
18
  # @!attribute [r] diaspora_id
19
- # Alias for author
19
+ # alias for author
20
20
  # @see Person#author
21
- # @return [String] diaspora ID
21
+ # @return [String] diaspora* ID
22
22
  property :author, alias: :diaspora_id, xml_name: :diaspora_handle
23
23
 
24
24
  # @!attribute [r] url
@@ -27,7 +27,7 @@ module DiasporaFederation
27
27
  property :url
28
28
 
29
29
  # @!attribute [r] profile
30
- # all profile data of the person
30
+ # All profile data of the person
31
31
  # @return [Profile] the profile of the person
32
32
  entity :profile, Entities::Profile
33
33
 
@@ -1,19 +1,19 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents photo and it is federated as a part of a status message
3
+ # This entity represents a photo and it is federated as a part of a status message.
4
4
  #
5
5
  # @see Validators::PhotoValidator
6
6
  class Photo < Entity
7
7
  # @!attribute [r] guid
8
- # a random string of at least 16 chars.
8
+ # A random string of at least 16 chars
9
9
  # @see Validation::Rule::Guid
10
10
  # @return [String] guid
11
11
  property :guid
12
12
 
13
13
  # @!attribute [r] author
14
- # The diaspora ID of the person who uploaded the photo
14
+ # The diaspora* ID of the person who uploaded the photo
15
15
  # @see Person#author
16
- # @return [String] author diaspora ID
16
+ # @return [String] author diaspora* ID
17
17
  property :author, xml_name: :diaspora_handle
18
18
 
19
19
  # @!attribute [r] public
@@ -22,12 +22,12 @@ module DiasporaFederation
22
22
  property :public, default: false
23
23
 
24
24
  # @!attribute [r] created_at
25
- # photo entity creation time
25
+ # Photo entity creation time
26
26
  # @return [Time] creation time
27
27
  property :created_at, default: -> { Time.now.utc }
28
28
 
29
29
  # @!attribute [r] remote_photo_path
30
- # an url of the photo on a remote server
30
+ # An url of the photo on a remote server
31
31
  # @return [String] remote photo url
32
32
  property :remote_photo_path
33
33
 
@@ -40,18 +40,18 @@ module DiasporaFederation
40
40
  property :text, default: nil
41
41
 
42
42
  # @!attribute [r] status_message_guid
43
- # guid of a status message this message belongs to
43
+ # Guid of a status message this photo belongs to
44
44
  # @see StatusMessage#guid
45
45
  # @return [String] guid
46
- property :status_message_guid
46
+ property :status_message_guid, default: nil
47
47
 
48
48
  # @!attribute [r] height
49
- # photo height
49
+ # Photo height
50
50
  # @return [String] height
51
51
  property :height
52
52
 
53
53
  # @!attribute [r] width
54
- # photo width
54
+ # Photo width
55
55
  # @return [String] width
56
56
  property :width
57
57
  end
@@ -1,11 +1,11 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a poll ant it is federated as an optional part of a status message
3
+ # This entity represents a poll and it is federated as an optional part of a status message.
4
4
  #
5
5
  # @see Validators::PollValidator
6
6
  class Poll < Entity
7
7
  # @!attribute [r] guid
8
- # a random string of at least 16 chars.
8
+ # A random string of at least 16 chars
9
9
  # @see Validation::Rule::Guid
10
10
  # @return [String] poll guid
11
11
  property :guid
@@ -16,7 +16,7 @@ module DiasporaFederation
16
16
  property :question
17
17
 
18
18
  # @!attribute [r] poll_answers
19
- # array of possible answer to the poll
19
+ # Array of possible answers for the poll
20
20
  # @return [[Entities::PollAnswer]] poll answers
21
21
  entity :poll_answers, [Entities::PollAnswer]
22
22
  end
@@ -1,11 +1,11 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a poll answer and is federated as a part of the Poll entity
3
+ # This entity represents a poll answer and is federated as a part of the Poll entity.
4
4
  #
5
5
  # @see Validators::PollAnswerValidator
6
6
  class PollAnswer < Entity
7
7
  # @!attribute [r] guid
8
- # a random string of at least 16 chars.
8
+ # A random string of at least 16 chars
9
9
  # @see Validation::Rule::Guid
10
10
  # @return [String] guid
11
11
  property :guid
@@ -1,10 +1,10 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity represents a participation in poll, i.e. it is issued when a user votes for an answer in a poll
3
+ # This entity represents a participation in poll, i.e. it is issued when a user votes for an answer in a poll.
4
4
  #
5
5
  # @see Validators::PollParticipationValidator
6
6
  class PollParticipation < Entity
7
- # old signature order
7
+ # Old signature order
8
8
  # @deprecated
9
9
  LEGACY_SIGNATURE_ORDER = %i(guid parent_guid author poll_answer_guid).freeze
10
10
 
@@ -14,7 +14,7 @@ module DiasporaFederation
14
14
  include Relayable
15
15
 
16
16
  # @!attribute [r] poll_answer_guid
17
- # guid of the answer selected by the user.
17
+ # Guid of the answer selected by the user
18
18
  # @see PollAnswer#guid
19
19
  # @return [String] poll answer guid
20
20
  property :poll_answer_guid
@@ -1,26 +1,26 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this is a module that defines common properties for a post which
3
+ # This is a module that defines common properties for a post which
4
4
  # include {StatusMessage} and {Reshare}.
5
5
  module Post
6
- # on inclusion of this module the required properties for a post are added to the object that includes it
6
+ # On inclusion of this module the required properties for a post are added to the object that includes it.
7
7
  #
8
8
  # @!attribute [r] author
9
- # The diaspora ID of the person who posts the post
9
+ # The diaspora* ID of the person who posts the post
10
10
  # @see Person#author
11
- # @return [String] diaspora ID
11
+ # @return [String] diaspora* ID
12
12
  #
13
13
  # @!attribute [r] guid
14
- # a random string of at least 16 chars.
14
+ # A random string of at least 16 chars
15
15
  # @see Validation::Rule::Guid
16
16
  # @return [String] status message guid
17
17
  #
18
18
  # @!attribute [r] created_at
19
- # post entity creation time
19
+ # Post entity creation time
20
20
  # @return [Time] creation time
21
21
  #
22
22
  # @!attribute [r] provider_display_name
23
- # a string that describes a means by which a user has posted the post
23
+ # A string that describes a means by which a user has posted the post
24
24
  # @return [String] provider display name
25
25
  #
26
26
  # @param [Entity] entity the entity in which it is included
@@ -1,22 +1,22 @@
1
1
  module DiasporaFederation
2
2
  module Entities
3
- # this entity contains all the profile data of a person
3
+ # This entity contains all the profile data of a person.
4
4
  #
5
5
  # @see Validators::ProfileValidator
6
6
  class Profile < Entity
7
7
  # @!attribute [r] author
8
- # The diaspora ID of the person
8
+ # The diaspora* ID of the person
9
9
  # @see Person#author
10
- # @return [String] diaspora ID
10
+ # @return [String] diaspora* ID
11
11
  # @!attribute [r] diaspora_id
12
12
  # Alias for author
13
13
  # @see Profile#author
14
- # @return [String] diaspora ID
14
+ # @return [String] diaspora* ID
15
15
  property :author, alias: :diaspora_id, xml_name: :diaspora_handle
16
16
 
17
17
  # @!attribute [r] first_name
18
18
  # @deprecated We decided to only use one name field, these should be removed
19
- # in later iterations (will affect older Diaspora* installations).
19
+ # in later iterations (will affect older diaspora* installations).
20
20
  # @see #full_name
21
21
  # @see Discovery::HCard#first_name
22
22
  # @return [String] first name
@@ -24,7 +24,7 @@ module DiasporaFederation
24
24
 
25
25
  # @!attribute [r] last_name
26
26
  # @deprecated We decided to only use one name field, these should be removed
27
- # in later iterations (will affect older Diaspora* installations).
27
+ # in later iterations (will affect older diaspora* installations).
28
28
  # @see #full_name
29
29
  # @see Discovery::HCard#last_name
30
30
  # @return [String] last name