activitypub 0.3.7 → 0.4.1
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 +4 -4
- data/examples/get_actor.rb +16 -1
- data/lib/activitypub/base.rb +16 -5
- data/lib/activitypub/types.rb +86 -21
- data/lib/activitypub/uri.rb +1 -1
- data/lib/activitypub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 422c4769d3efddf0251d5cb9f64f92b6f4c9c72c054bed80bd2e2e4d74fb6870
|
4
|
+
data.tar.gz: 8d503eed716a1a54d62e654ba647415c6d9b89cfeb060bedc6dbc52a1735aaf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 487e02cb6426a2ac76d3ccedcea22f9fe1693b697aea51969b16d0164a1e9fdbc8233c355182e2e695b04177a4bd2e81f05cb4e25090f972a36938f6cc4260b1
|
7
|
+
data.tar.gz: 6ca2c9ca57226499972c51b6d9017a96ace046964d754e0a8eaa46ae5b0d6441d900c473cd16d6ed670eed3838b0181e1f7b31fb7b29d757b0324cb2d2ed066a
|
data/examples/get_actor.rb
CHANGED
@@ -30,10 +30,25 @@ puts
|
|
30
30
|
|
31
31
|
ob = href.get
|
32
32
|
PP.pp(ob)
|
33
|
+
#puts ob.to_json
|
33
34
|
puts
|
34
35
|
puts "Enter to continue"
|
35
36
|
gets
|
36
37
|
|
37
38
|
puts "Trying to retrieve outbox"
|
38
|
-
ob =
|
39
|
+
ob = ob.outbox.get
|
39
40
|
PP.pp(ob)
|
41
|
+
puts
|
42
|
+
puts "Enter to continue"
|
43
|
+
gets
|
44
|
+
|
45
|
+
puts
|
46
|
+
puts "PAGE: #{ob.first}"
|
47
|
+
ob = ob.first.get
|
48
|
+
PP.pp(ob)
|
49
|
+
|
50
|
+
# For now, this will let you iterate through the collection.
|
51
|
+
# while ob && ob.orderedItems.length > 0
|
52
|
+
# PP.pp ob.id
|
53
|
+
# ob = ob.next&.get
|
54
|
+
# end
|
data/lib/activitypub/base.rb
CHANGED
@@ -22,6 +22,9 @@ module ActivityPub
|
|
22
22
|
|
23
23
|
ob = klass ? klass.new : nil
|
24
24
|
|
25
|
+
# FIXME: Useful for debug. Add flag to allow enabling.
|
26
|
+
# ob.instance_variable_set("@_raw",h)
|
27
|
+
|
25
28
|
if ob
|
26
29
|
context = h.dig("@context")
|
27
30
|
ob.instance_variable_set("@_context", context) if context
|
@@ -36,8 +39,9 @@ module ActivityPub
|
|
36
39
|
av.is_a?(Hash) && av["type"] ? from_hash(av) : av
|
37
40
|
end
|
38
41
|
end
|
39
|
-
|
40
|
-
|
42
|
+
|
43
|
+
if t = klass.ap_types[attr]
|
44
|
+
v = t.new(v) if v
|
41
45
|
end
|
42
46
|
ob.instance_variable_set("@#{attr}", v) if !v.nil?
|
43
47
|
end
|
@@ -55,12 +59,19 @@ module ActivityPub
|
|
55
59
|
|
56
60
|
|
57
61
|
# FIXME: Allow specifying a type (e.g. URI)
|
58
|
-
def self.ap_attr(
|
62
|
+
def self.ap_attr(name, type=nil)
|
59
63
|
@ap_attributes ||= []
|
60
|
-
@ap_attributes
|
61
|
-
|
64
|
+
@ap_attributes << name
|
65
|
+
@ap_types ||= {}
|
66
|
+
@ap_types[name] = type
|
67
|
+
attr_accessor name
|
62
68
|
end
|
63
69
|
|
70
|
+
def self.ap_types
|
71
|
+
parent = superclass.respond_to?(:ap_types) ? superclass.ap_types : {}
|
72
|
+
parent.merge(@ap_types || {})
|
73
|
+
end
|
74
|
+
|
64
75
|
def self.ap_attributes
|
65
76
|
parent = superclass.respond_to?(:ap_attributes) ? superclass.ap_attributes : []
|
66
77
|
parent.concat(@ap_attributes||[])
|
data/lib/activitypub/types.rb
CHANGED
@@ -7,19 +7,57 @@ require_relative 'uri'
|
|
7
7
|
module ActivityPub
|
8
8
|
|
9
9
|
class Link < Base
|
10
|
-
ap_attr :href,
|
10
|
+
ap_attr :href, URI
|
11
|
+
|
12
|
+
# We don't mark "rel" as a URI as it's effectively
|
13
|
+
# used as an identifier for comparison rather than to
|
14
|
+
# dereference
|
15
|
+
ap_attr :rel
|
16
|
+
|
17
|
+
ap_attr :mediaType
|
18
|
+
ap_attr :name
|
19
|
+
ap_attr :hreflang
|
20
|
+
ap_attr :height
|
21
|
+
ap_attr :width
|
22
|
+
ap_attr :preview
|
11
23
|
end
|
12
24
|
|
13
25
|
class Object < Base
|
14
26
|
ap_attr :id
|
15
|
-
ap_attr :attachment
|
16
|
-
|
17
|
-
|
18
|
-
|
27
|
+
ap_attr :attachment
|
28
|
+
ap_attr :attributedTo
|
29
|
+
ap_attr :audience
|
30
|
+
ap_attr :content
|
31
|
+
ap_attr :context
|
32
|
+
ap_attr :name
|
33
|
+
ap_attr :endTime
|
34
|
+
ap_attr :generator
|
35
|
+
ap_attr :icon
|
36
|
+
ap_attr :image
|
37
|
+
ap_attr :inReplyTo, URI
|
38
|
+
ap_attr :location
|
39
|
+
ap_attr :preview
|
40
|
+
ap_attr :published
|
41
|
+
ap_attr :replies
|
42
|
+
ap_attr :startTime
|
43
|
+
ap_attr :summary
|
44
|
+
ap_attr :tag
|
45
|
+
ap_attr :updated
|
46
|
+
ap_attr :url, URI
|
47
|
+
ap_attr :to
|
48
|
+
ap_attr :bto
|
49
|
+
ap_attr :cc
|
50
|
+
ap_attr :mediaType
|
51
|
+
ap_attr :duration
|
19
52
|
end
|
20
53
|
|
21
54
|
class Activity < Object
|
22
|
-
ap_attr :actor
|
55
|
+
ap_attr :actor
|
56
|
+
ap_attr :object
|
57
|
+
ap_attr :target
|
58
|
+
ap_attr :result
|
59
|
+
ap_attr :origin
|
60
|
+
ap_attr :instrument
|
23
61
|
end
|
24
62
|
|
25
63
|
# @FIXME
|
@@ -28,7 +66,11 @@ module ActivityPub
|
|
28
66
|
end
|
29
67
|
|
30
68
|
class Collection < Object
|
31
|
-
ap_attr :totalItems
|
69
|
+
ap_attr :totalItems
|
70
|
+
ap_attr :current
|
71
|
+
ap_attr :first, URI
|
72
|
+
ap_attr :last, URI
|
73
|
+
ap_attr :items
|
32
74
|
end
|
33
75
|
|
34
76
|
class OrderedCollection < Collection
|
@@ -42,10 +84,18 @@ module ActivityPub
|
|
42
84
|
end
|
43
85
|
|
44
86
|
class CollectionPage < Collection
|
45
|
-
ap_attr :partOf,
|
87
|
+
ap_attr :partOf, URI
|
88
|
+
ap_attr :next, URI
|
89
|
+
ap_attr :prev, URI
|
46
90
|
end
|
47
|
-
|
48
|
-
|
91
|
+
|
92
|
+
# FIXME: OrderedCollectionPage inherits both CollectionPage and
|
93
|
+
# OrderedCollection.
|
94
|
+
#
|
95
|
+
class OrderedCollectionPage < OrderedCollection
|
96
|
+
ap_attr :partOf, URI
|
97
|
+
ap_attr :next, URI
|
98
|
+
ap_attr :prev, URI
|
49
99
|
ap_attr :startIndex
|
50
100
|
end
|
51
101
|
|
@@ -130,7 +180,9 @@ module ActivityPub
|
|
130
180
|
end
|
131
181
|
|
132
182
|
class Question < IntransitiveActivity
|
133
|
-
ap_attr :oneOf
|
183
|
+
ap_attr :oneOf
|
184
|
+
ap_attr :anyOf
|
185
|
+
ap_attr :closed
|
134
186
|
end
|
135
187
|
|
136
188
|
# ## Actor Types
|
@@ -144,20 +196,27 @@ module ActivityPub
|
|
144
196
|
# Section 4.1
|
145
197
|
|
146
198
|
# MUST have:
|
147
|
-
ap_attr :inbox,
|
199
|
+
ap_attr :inbox, URI
|
200
|
+
ap_attr :outbox, URI
|
148
201
|
|
149
202
|
# SHOULD have:
|
150
|
-
ap_attr :following
|
203
|
+
ap_attr :following
|
204
|
+
ap_attr :followers
|
151
205
|
|
152
206
|
# MAY have:
|
153
|
-
ap_attr :liked
|
154
|
-
|
207
|
+
ap_attr :liked
|
208
|
+
ap_attr :streams
|
209
|
+
ap_attr :preferredUsername
|
210
|
+
ap_attr :endpoints
|
155
211
|
|
156
212
|
|
157
213
|
# Per https://docs-p.joinmastodon.org/spec/activitypub/#extensions
|
158
214
|
# These are extensions used by Mastodon for Actor types
|
159
|
-
ap_attr :publicKey
|
160
|
-
|
215
|
+
ap_attr :publicKey
|
216
|
+
ap_attr :featured
|
217
|
+
ap_attr :featuredTags
|
218
|
+
ap_attr :discoverable
|
219
|
+
ap_attr :suspended
|
161
220
|
end
|
162
221
|
|
163
222
|
# FIXME: Add "toot:Emoji
|
@@ -173,7 +232,9 @@ module ActivityPub
|
|
173
232
|
|
174
233
|
# Mastodon extension per
|
175
234
|
# https://docs-p.joinmastodon.org/spec/activitypub/#extensions
|
176
|
-
ap_attr :likes
|
235
|
+
ap_attr :likes
|
236
|
+
ap_attr :bookmarks
|
237
|
+
ap_attr :manuallyApprovesFollowers
|
177
238
|
end
|
178
239
|
|
179
240
|
class Service < Actor
|
@@ -183,7 +244,9 @@ module ActivityPub
|
|
183
244
|
# ## Object types
|
184
245
|
|
185
246
|
class Relationship < Object
|
186
|
-
ap_attr :subject
|
247
|
+
ap_attr :subject
|
248
|
+
ap_attr :object
|
249
|
+
ap_attr :relationship
|
187
250
|
end
|
188
251
|
|
189
252
|
class Article < Object
|
@@ -199,7 +262,8 @@ module ActivityPub
|
|
199
262
|
|
200
263
|
# Mastodon extension per
|
201
264
|
# https://docs-p.joinmastodon.org/spec/activitypub/#extensions
|
202
|
-
ap_attr :focalPoint
|
265
|
+
ap_attr :focalPoint
|
266
|
+
ap_attr :blurhash
|
203
267
|
end
|
204
268
|
|
205
269
|
class Video < Document
|
@@ -224,7 +288,8 @@ module ActivityPub
|
|
224
288
|
end
|
225
289
|
|
226
290
|
class Tombstone < Object
|
227
|
-
ap_attr :formerType
|
291
|
+
ap_attr :formerType
|
292
|
+
ap_attr :deleted
|
228
293
|
end
|
229
294
|
|
230
295
|
# Mastodon extensions
|
data/lib/activitypub/uri.rb
CHANGED
data/lib/activitypub/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.1
|
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-
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webfinger
|