activitypub 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/activitypub/base.rb +24 -1
- data/lib/activitypub/types.rb +5 -0
- 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: 112ee8d199c09e5d9ff788e2bdf02b80e745513a8812d01cfbf377fb56daac3b
|
4
|
+
data.tar.gz: 7132a7c5d296315c29dad6672a511841a0557640d2b43139d1d4399c71e10487
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f3d2e3788239c080ac7354fa5a02e27ac242911374d86b579473c0ae451f1d46eff8033b7ae91abb8cda24e865cf9c58ebfd2fbc2c86257b4ed01e3856f0a4
|
7
|
+
data.tar.gz: 8c7b248e72822ca739272b4315fc3256aefe96a333b81ca0676a5717162fd345a6ff2e3eef2ff3d989172abbad8124a652c5aa6cf105c1a7880643aa20c03c53
|
data/README.md
CHANGED
@@ -3,6 +3,18 @@
|
|
3
3
|
*Very* early start on a set of classes to serialize/deserialize
|
4
4
|
ActivityPub/ActivityStream objects.
|
5
5
|
|
6
|
+
## Goals
|
7
|
+
|
8
|
+
* To provide a fairly *minimalist*, *barebones* set of classes to
|
9
|
+
work with ActivityPub objects *as used* by major Fediverse apps.
|
10
|
+
* Matching real-world use will be prioritized over strict adherence
|
11
|
+
to the specs - my use-cases require me to be able to handle documents
|
12
|
+
even if they have errors. But I want to be able to *produce* output
|
13
|
+
that prefers standards compliance where it doesn't sacrifice interop.
|
14
|
+
* Support extensions and namespace used by e.g. Mastodon and others.
|
15
|
+
* Be easy to extend/layer new functionality on top of for anything
|
16
|
+
that doesn't fit in this core.
|
17
|
+
|
6
18
|
|
7
19
|
## Installation
|
8
20
|
|
data/lib/activitypub/base.rb
CHANGED
@@ -1,11 +1,34 @@
|
|
1
1
|
|
2
|
+
require 'json'
|
3
|
+
|
2
4
|
module ActivityPub
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
def self.from_json(json)
|
8
|
+
h = JSON.parse(json)
|
9
|
+
type = h&.dig("type")
|
10
|
+
|
11
|
+
raise Error, "'type' attribute is required" if !type
|
12
|
+
raise NameError, "'type' attribute with '::' is not allowed" if !type.index("::").nil?
|
13
|
+
|
14
|
+
klass = ActivityPub.const_get(type)
|
3
15
|
|
16
|
+
ob = klass ? klass.new : nil
|
17
|
+
|
18
|
+
if ob
|
19
|
+
klass.ap_attributes.each do |attr|
|
20
|
+
ob.instance_variable_set("@#{attr}", h.dig(attr.to_s))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
ob
|
25
|
+
end
|
26
|
+
|
4
27
|
# This is not part of ActivityPub, but provides basic mechanisms
|
5
28
|
# for serialization and dezerialisation.
|
6
29
|
#
|
7
30
|
class Base
|
8
|
-
def _context = "https://www.w3.org/ns/activitystreams"
|
31
|
+
def _context = "https://www.w3.org/ns/activitystreams".freeze
|
9
32
|
def _type = self.class.name.split("::").last
|
10
33
|
|
11
34
|
|
data/lib/activitypub/types.rb
CHANGED
@@ -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,
|
@@ -161,6 +162,10 @@ module ActivityPub
|
|
161
162
|
end
|
162
163
|
|
163
164
|
class Person < Actor
|
165
|
+
|
166
|
+
# Mastodon extension per
|
167
|
+
# https://docs-p.joinmastodon.org/spec/activitypub/#extensions
|
168
|
+
ap_attr :likes, :bookmarks, :manuallyApprovesFollowers
|
164
169
|
end
|
165
170
|
|
166
171
|
class Service < Actor
|
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.3.
|
4
|
+
version: 0.3.2
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|