activitypub 0.3.5 → 0.3.7
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/Gemfile +6 -0
- data/examples/Gemfile.lock +48 -0
- data/examples/get_actor.rb +39 -0
- data/lib/activitypub/base.rb +5 -1
- data/lib/activitypub/types.rb +1 -0
- data/lib/activitypub/uri.rb +23 -0
- data/lib/activitypub/version.rb +1 -1
- data/lib/activitypub/webfinger.rb +27 -0
- data/lib/activitypub.rb +3 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58943510abdbebb4cce7084adcd2fd5c587abed81f103db968148248a9b1e7c1
|
4
|
+
data.tar.gz: 5ccd6bd6cff637fdc5717d064b8b02a29282c9e6d7549c8ad322bd30a0ce2503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a8b4a3a8cdac1be9d069c47b413d00573640ad59e0deca098bf0a0b5f06124bd3c2a43b66462b2f3bf23b3b187c0de55478878b875fa38674b7c53eac968b54
|
7
|
+
data.tar.gz: c4981e523c2754b2d83c9cf6f52fc6de61353b3373097a55b5531f325b08c1477195ba7bac58f3ee47eb3138cb743d06c1719f61e3779a06a3f9b45112011770
|
data/examples/Gemfile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (7.1.3.4)
|
5
|
+
base64
|
6
|
+
bigdecimal
|
7
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
8
|
+
connection_pool (>= 2.2.5)
|
9
|
+
drb
|
10
|
+
i18n (>= 1.6, < 2)
|
11
|
+
minitest (>= 5.1)
|
12
|
+
mutex_m
|
13
|
+
tzinfo (~> 2.0)
|
14
|
+
base64 (0.2.0)
|
15
|
+
bigdecimal (3.1.8)
|
16
|
+
concurrent-ruby (1.3.3)
|
17
|
+
connection_pool (2.4.1)
|
18
|
+
drb (2.2.1)
|
19
|
+
faraday (2.10.0)
|
20
|
+
faraday-net_http (>= 2.0, < 3.2)
|
21
|
+
logger
|
22
|
+
faraday-follow_redirects (0.3.0)
|
23
|
+
faraday (>= 1, < 3)
|
24
|
+
faraday-net_http (3.1.0)
|
25
|
+
net-http
|
26
|
+
i18n (1.14.5)
|
27
|
+
concurrent-ruby (~> 1.0)
|
28
|
+
logger (1.6.0)
|
29
|
+
minitest (5.24.1)
|
30
|
+
mutex_m (0.2.0)
|
31
|
+
net-http (0.4.1)
|
32
|
+
uri
|
33
|
+
tzinfo (2.0.6)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
uri (0.13.0)
|
36
|
+
webfinger (2.1.3)
|
37
|
+
activesupport
|
38
|
+
faraday (~> 2.0)
|
39
|
+
faraday-follow_redirects
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
x86_64-linux
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
webfinger
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.4.19
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
require 'pp'
|
3
|
+
$: << File.expand_path(__FILE__ + "/../../lib")
|
4
|
+
require 'activitypub'
|
5
|
+
|
6
|
+
acct = ARGV.shift || "vidar@galaxybound.com"
|
7
|
+
|
8
|
+
puts "Trying webfinger for #{acct} (to choose your own account, provide it as an argument)"
|
9
|
+
puts
|
10
|
+
|
11
|
+
wf = ActivityPub.webfinger(acct)
|
12
|
+
if !wf
|
13
|
+
puts "Unable to find #{acct}"
|
14
|
+
exit(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
PP.pp wf
|
18
|
+
puts
|
19
|
+
puts "Enter to continue"
|
20
|
+
gets
|
21
|
+
|
22
|
+
href = wf.activitypub
|
23
|
+
if !href
|
24
|
+
puts "Unable to find a link to the actor"
|
25
|
+
exit(2)
|
26
|
+
end
|
27
|
+
|
28
|
+
puts "Trying to retrieve the Actor from #{href}"
|
29
|
+
puts
|
30
|
+
|
31
|
+
ob = href.get
|
32
|
+
PP.pp(ob)
|
33
|
+
puts
|
34
|
+
puts "Enter to continue"
|
35
|
+
gets
|
36
|
+
|
37
|
+
puts "Trying to retrieve outbox"
|
38
|
+
ob = ActivityPub::URI.new(ob.outbox).get
|
39
|
+
PP.pp(ob)
|
data/lib/activitypub/base.rb
CHANGED
@@ -36,7 +36,10 @@ module ActivityPub
|
|
36
36
|
av.is_a?(Hash) && av["type"] ? from_hash(av) : av
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
if attr.to_s == "href" && v.is_a?(String)
|
40
|
+
v = ActivityPub::URI.new(v)
|
41
|
+
end
|
42
|
+
ob.instance_variable_set("@#{attr}", v) if !v.nil?
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -51,6 +54,7 @@ module ActivityPub
|
|
51
54
|
def _type = self.class.name.split("::").last
|
52
55
|
|
53
56
|
|
57
|
+
# FIXME: Allow specifying a type (e.g. URI)
|
54
58
|
def self.ap_attr(*names)
|
55
59
|
@ap_attributes ||= []
|
56
60
|
@ap_attributes.concat(names)
|
data/lib/activitypub/types.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
require 'uri'
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
module ActivityPub
|
6
|
+
class URI
|
7
|
+
def initialize(href)
|
8
|
+
@href = href
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s = @href
|
12
|
+
def to_json = @href
|
13
|
+
|
14
|
+
def get
|
15
|
+
response = Faraday.get(self.to_s, {}, {"Accept": "application/activity+json"})
|
16
|
+
if response.status == 200
|
17
|
+
ActivityPub.from_json(response.body)
|
18
|
+
else
|
19
|
+
response
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/activitypub/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'webfinger'
|
3
|
+
|
4
|
+
module ActivityPub
|
5
|
+
class WebFingerResult
|
6
|
+
def initialize(hash)
|
7
|
+
@h = hash
|
8
|
+
|
9
|
+
@h["aliases"] = @h["aliases"].map{ ActivityPub::URI.new(_1) }
|
10
|
+
@h["links"].each do |v|
|
11
|
+
if v["href"]
|
12
|
+
v["href"] = ActivityPub::URI.new(v["href"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def[](i) = @h[i]
|
18
|
+
|
19
|
+
def activitypub
|
20
|
+
@activitypub ||= self["links"].find{ _1["rel"] == "self" && _1["type"] == "application/activity+json" }&.dig("href")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.webfinger(acct)
|
25
|
+
WebFingerResult.new(WebFinger.discover!(acct))
|
26
|
+
end
|
27
|
+
end
|
data/lib/activitypub.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "activitypub/version"
|
4
|
+
require_relative "activitypub/base"
|
4
5
|
require_relative "activitypub/types"
|
6
|
+
require_relative "activitypub/uri"
|
7
|
+
require_relative "activitypub/webfinger"
|
5
8
|
|
6
9
|
module ActivityPub
|
7
10
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.7
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: webfinger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.3
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
- vidar@hokstad.com
|
@@ -21,10 +35,15 @@ files:
|
|
21
35
|
- LICENSE.txt
|
22
36
|
- README.md
|
23
37
|
- Rakefile
|
38
|
+
- examples/Gemfile
|
39
|
+
- examples/Gemfile.lock
|
40
|
+
- examples/get_actor.rb
|
24
41
|
- lib/activitypub.rb
|
25
42
|
- lib/activitypub/base.rb
|
26
43
|
- lib/activitypub/types.rb
|
44
|
+
- lib/activitypub/uri.rb
|
27
45
|
- lib/activitypub/version.rb
|
46
|
+
- lib/activitypub/webfinger.rb
|
28
47
|
- sig/activitypub.rbs
|
29
48
|
homepage: https://github.com/vidarh/activitypub
|
30
49
|
licenses:
|