Skip to content

Commit 3ab2468

Browse files
committed
Add data sharing engine
Basic engine to perform `data_sharing` with a fediverse server. It includes all the basic building blocks (APIs + code to fetch content from fediverse servers authenticating as a proper actor). Shared content results in the queuing of an (empty) ActiveJob. FASP need to implement these jobs to do something meaningful. The debug provider has been extended to use this to subscribe to content and (so far) fetch new content when it arrives.
1 parent b365a1e commit 3ab2468

File tree

157 files changed

+3348
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+3348
-43
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI - fasp_data_sharing
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "fasp_data_sharing/**"
7+
push:
8+
branches: [ main ]
9+
paths:
10+
- "fasp_data_sharing/**"
11+
12+
defaults:
13+
run:
14+
working-directory: ./fasp_data_sharing
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Ruby
24+
uses: ruby/setup-ruby@v1
25+
with:
26+
ruby-version: ruby-3.3.6
27+
bundler-cache: true
28+
29+
- name: Lint code for consistent style
30+
run: bin/rubocop -f github
31+
32+
test:
33+
runs-on: ubuntu-latest
34+
35+
# services:
36+
# redis:
37+
# image: redis
38+
# ports:
39+
# - 6379:6379
40+
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
41+
steps:
42+
- name: Install packages
43+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3
44+
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Set up Ruby
49+
uses: ruby/setup-ruby@v1
50+
with:
51+
ruby-version: ruby-3.3.6
52+
bundler-cache: true
53+
54+
- name: Run tests
55+
env:
56+
RAILS_ENV: test
57+
# REDIS_URL: redis://localhost:6379/0
58+
run: bin/rails db:test:prepare test
59+
60+
- name: Keep screenshots from failed system tests
61+
uses: actions/upload-artifact@v4
62+
if: failure()
63+
with:
64+
name: screenshots
65+
path: ${{ github.workspace }}/tmp/screenshots
66+
if-no-files-found: ignore
67+

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Ruby FASP SDK
2+
3+
A set of rails engines and a sample debug provider to facilitate
4+
development of Fediverse Auxiliary Service Providers (FASP).
5+
6+
## Contents
7+
8+
* [`fasp_base`](fasp_base/)
9+
A rails engine with the basics of provider-server interactions
10+
(registration, provider info, API authentication). Includes a simple
11+
server-rendered HTML frontend, but could be used headless as well.
12+
* [`fasp_data_sharing`](fasp_data_sharing/)
13+
A rails engine implementing most of the `data_sharing` discovery
14+
capability. Can be dropped into any FASP, which will only need to
15+
trigger subscriptions/backfill requests and implement background jobs
16+
to handle the URIs it receives. Also includes code to perform an
17+
"authorized fetch" of fediverse resources.
18+
* [`debug`](debug/)
19+
A sample debug provider that utilizes both engines above to provide
20+
the `debug` capability and experiment with `data_sharing`.
21+
22+
## Contributing
23+
24+
See https://github.com/mastodon/.github/blob/main/CONTRIBUTING.md
25+
26+
## License
27+
28+
The code in this repository is available as open source under the terms
29+
of the [MIT License](https://opensource.org/licenses/MIT).

debug_fasp/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ gem "bootsnap", require: false
3636
gem "thruster", require: false
3737

3838
gem "fasp_base", path: "../fasp_base"
39+
gem "fasp_data_sharing", path: "../fasp_data_sharing"
3940

4041
group :development, :test do
4142
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem

debug_fasp/Gemfile.lock

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ PATH
88
openssl
99
rails (>= 8.0.0)
1010

11+
PATH
12+
remote: ../fasp_data_sharing
13+
specs:
14+
fasp_data_sharing (0.1.0)
15+
fasp_base
16+
rails (>= 8.0.0)
17+
1118
GEM
1219
remote: https://rubygems.org/
1320
specs:
@@ -115,7 +122,6 @@ GEM
115122
irb (~> 1.10)
116123
reline (>= 0.3.8)
117124
drb (2.2.1)
118-
ed25519 (1.3.0)
119125
erubi (1.13.0)
120126
et-orbi (1.2.11)
121127
tzinfo
@@ -143,11 +149,11 @@ GEM
143149
activesupport (>= 5.0.0)
144150
json (2.9.0)
145151
language_server-protocol (3.17.0.3)
146-
linzer (0.6.1)
147-
ed25519 (~> 1.3, >= 1.3.0)
152+
linzer (0.6.2)
148153
openssl (~> 3.0, >= 3.0.0)
149154
rack (>= 2.2, < 4.0)
150155
starry (~> 0.2)
156+
stringio (~> 3.1, >= 3.1.2)
151157
uri (~> 1.0, >= 1.0.2)
152158
logger (1.6.2)
153159
loofah (2.23.1)
@@ -313,12 +319,12 @@ GEM
313319
tailwindcss-rails (3.0.0)
314320
railties (>= 7.0.0)
315321
tailwindcss-ruby
316-
tailwindcss-ruby (3.4.15)
317-
tailwindcss-ruby (3.4.15-aarch64-linux)
318-
tailwindcss-ruby (3.4.15-arm-linux)
319-
tailwindcss-ruby (3.4.15-arm64-darwin)
320-
tailwindcss-ruby (3.4.15-x86_64-darwin)
321-
tailwindcss-ruby (3.4.15-x86_64-linux)
322+
tailwindcss-ruby (3.4.16)
323+
tailwindcss-ruby (3.4.16-aarch64-linux)
324+
tailwindcss-ruby (3.4.16-arm-linux)
325+
tailwindcss-ruby (3.4.16-arm64-darwin)
326+
tailwindcss-ruby (3.4.16-x86_64-darwin)
327+
tailwindcss-ruby (3.4.16-x86_64-linux)
322328
thor (1.3.2)
323329
thruster (0.1.9)
324330
thruster (0.1.9-aarch64-linux)
@@ -375,6 +381,7 @@ DEPENDENCIES
375381
capybara
376382
debug
377383
fasp_base!
384+
fasp_data_sharing!
378385
importmap-rails
379386
jbuilder
380387
propshaft
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class AccountsController < ApplicationController
2+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ContentsController < ApplicationController
2+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class SubscriptionsController < ApplicationController
2+
def index
3+
@subscriptions = FaspDataSharing::Subscription.all
4+
end
5+
6+
def create
7+
FaspDataSharing::Subscription.subscribe_to_content(current_user.servers.first)
8+
9+
redirect_to subscriptions_path, notice: t(".success")
10+
end
11+
12+
def destroy
13+
subscription = FaspDataSharing::Subscription.where(fasp_base_server_id: current_user.server_ids).find(params[:id])
14+
subscription.destroy
15+
16+
redirect_to subscriptions_path, notice: t(".success")
17+
end
18+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module AccountsHelper
2+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ContentsHelper
2+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module SubscriptionsHelper
2+
end

0 commit comments

Comments
 (0)