activitypub 0.3.1 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d6b1c47f6ac1051a3057f0ae8d57fe2d83c3c99aea99a45ff09c50f1f044a9b
4
- data.tar.gz: df120e3bad47452d3a22bb400feab41db3b4c27502b16247f389c751373ccb9b
3
+ metadata.gz: 17f43a4f939aa54391fce983f65b2599fce783d3c1f5cb1fbeadf92bc56bf63f
4
+ data.tar.gz: 1f527109c8f80bb80fa6c4b6af988dc1672219757c2177b2bcdff6e6c529ce8a
5
5
  SHA512:
6
- metadata.gz: bc9e697ab7e8b67c040c482d9ba1f63ada540f5b2d08a5da689495670f960a71900b21e11548c8fe97ddc205bb5185afa5273c20df53bea9ddd36a1633d8cc6d
7
- data.tar.gz: 27545eed23569575170cff387692c3d48ffe94c3afe0a9f417d37c121442852d3f5d145e4416ce5bec41c074a2e6ece46d4875183381c0c8b37d8bbb2d1821fd
6
+ metadata.gz: ee5dab8ee0ed11b02aa08e878b0e35844244a7894248da373c8441cd3aebede599e66fdcc175b2b7d3f172ed6f79ba6e2edc0d0bedb3f6bb32a5589822a59bc6
7
+ data.tar.gz: 5090b6f6dc1b4fc61219f542a28ca5415387270354912c5f2a8c967fcd8404f2044aac6f91424d5e10359550881b2649edc20cdc93878c618bbe2f61055f37f8
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'json'
3
4
 
@@ -10,17 +11,30 @@ module ActivityPub
10
11
 
11
12
  raise Error, "'type' attribute is required" if !type
12
13
  raise NameError, "'type' attribute with '::' is not allowed" if !type.index("::").nil?
14
+
15
+ # FIXME: May need a way to override/handle custom namespaces.
13
16
 
14
17
  klass = ActivityPub.const_get(type)
15
18
 
16
- klass ? klass.new : nil
19
+ ob = klass ? klass.new : nil
20
+
21
+ if ob
22
+ context = h.dig("@context")
23
+ ob.instance_variable_set("@_context", context) if context
24
+
25
+ klass.ap_attributes.each do |attr|
26
+ ob.instance_variable_set("@#{attr}", h.dig(attr.to_s))
27
+ end
28
+ end
29
+
30
+ ob
17
31
  end
18
32
 
19
33
  # This is not part of ActivityPub, but provides basic mechanisms
20
34
  # for serialization and dezerialisation.
21
35
  #
22
36
  class Base
23
- def _context = "https://www.w3.org/ns/activitystreams".freeze
37
+ def _context = @_context || "https://www.w3.org/ns/activitystreams"
24
38
  def _type = self.class.name.split("::").last
25
39
 
26
40
 
@@ -10,6 +10,7 @@ module ActivityPub
10
10
  end
11
11
 
12
12
  class Object < Base
13
+ ap_attr :id
13
14
  ap_attr :attachment, :attributedTo, :audience, :content, :context,
14
15
  :name, :endTime, :generator, :icon, :image, :inReplyTo, :location,
15
16
  :preview, :published, :replies, :startTime, :summary, :tag, :updated,
@@ -30,6 +31,13 @@ module ActivityPub
30
31
  end
31
32
 
32
33
  class OrderedCollection < Collection
34
+ # "orderedItems" is not part of
35
+ # https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection,
36
+ # however it is part of at least some Mastodon exports, and so we include
37
+ # it here
38
+ #
39
+ # FIXME: Review/consider whether to marge orderedItems/items internally.
40
+ ap_attr :orderedItems
33
41
  end
34
42
 
35
43
  class CollectionPage < Collection
@@ -161,6 +169,10 @@ module ActivityPub
161
169
  end
162
170
 
163
171
  class Person < Actor
172
+
173
+ # Mastodon extension per
174
+ # https://docs-p.joinmastodon.org/spec/activitypub/#extensions
175
+ ap_attr :likes, :bookmarks, :manuallyApprovesFollowers
164
176
  end
165
177
 
166
178
  class Service < Actor
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivityPub
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activitypub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vidar Hokstad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: