activitypub 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17f43a4f939aa54391fce983f65b2599fce783d3c1f5cb1fbeadf92bc56bf63f
4
- data.tar.gz: 1f527109c8f80bb80fa6c4b6af988dc1672219757c2177b2bcdff6e6c529ce8a
3
+ metadata.gz: 8c0e1247ee89de99f86956188ce6bd17a3a5360b9abb222badc18b2671cca5b9
4
+ data.tar.gz: eeede65bac6dd07a3ba9acdb9569d764448d2ff06816e59741431f9a8f3fdbff
5
5
  SHA512:
6
- metadata.gz: ee5dab8ee0ed11b02aa08e878b0e35844244a7894248da373c8441cd3aebede599e66fdcc175b2b7d3f172ed6f79ba6e2edc0d0bedb3f6bb32a5589822a59bc6
7
- data.tar.gz: 5090b6f6dc1b4fc61219f542a28ca5415387270354912c5f2a8c967fcd8404f2044aac6f91424d5e10359550881b2649edc20cdc93878c618bbe2f61055f37f8
6
+ metadata.gz: 62a13084316cbf4c333ab333f41639a1a41ec29e72d53c5a9ab61a82b13396a08eb553e2c147d9c2a35dc197756859f2c11d5c6dccfd8525573a2c1f9a74bbe3
7
+ data.tar.gz: acdb52191d7b1fc1ca31178dc8becbeaeac3c97e4a4c14e2fba27fee3ca22722edb3c766cc3d98a9188181541a8b6384643ee3d241953558fd44360d36418c95
@@ -4,9 +4,13 @@ require 'json'
4
4
 
5
5
  module ActivityPub
6
6
  class Error < StandardError; end
7
+
7
8
 
8
9
  def self.from_json(json)
9
- h = JSON.parse(json)
10
+ from_hash(JSON.parse(json))
11
+ end
12
+
13
+ def self.from_hash(h)
10
14
  type = h&.dig("type")
11
15
 
12
16
  raise Error, "'type' attribute is required" if !type
@@ -23,7 +27,16 @@ module ActivityPub
23
27
  ob.instance_variable_set("@_context", context) if context
24
28
 
25
29
  klass.ap_attributes.each do |attr|
26
- ob.instance_variable_set("@#{attr}", h.dig(attr.to_s))
30
+ v = h.dig(attr.to_s)
31
+
32
+ if v.is_a?(Hash) && v["type"]
33
+ v = from_hash(v)
34
+ elsif v.is_a?(Array)
35
+ v = v.map do |av|
36
+ av.is_a?(Hash) && av["type"] ? from_hash(av) : av
37
+ end
38
+ end
39
+ ob.instance_variable_set("@#{attr}", v)
27
40
  end
28
41
  end
29
42
 
@@ -225,4 +225,13 @@ module ActivityPub
225
225
  class Tombstone < Object
226
226
  ap_attr :formerType, :deleted
227
227
  end
228
+
229
+ # Mastodon extensions
230
+
231
+ class Hashtag < Link
232
+ end
233
+
234
+ class PropertyValue < Object
235
+ ap_attr :value
236
+ end
228
237
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivityPub
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.5"
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.4
4
+ version: 0.3.5
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-04 00:00:00.000000000 Z
11
+ date: 2024-07-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: