federails 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -1
  3. data/app/controllers/federails/client/activities_controller.rb +9 -3
  4. data/app/controllers/federails/client/actors_controller.rb +5 -2
  5. data/app/controllers/federails/client/followings_controller.rb +13 -3
  6. data/app/controllers/federails/client_controller.rb +9 -0
  7. data/app/controllers/federails/server/activities_controller.rb +11 -6
  8. data/app/controllers/federails/server/actors_controller.rb +6 -2
  9. data/app/controllers/federails/server/followings_controller.rb +3 -2
  10. data/app/controllers/federails/server/nodeinfo_controller.rb +13 -7
  11. data/app/controllers/federails/server/web_finger_controller.rb +7 -3
  12. data/app/controllers/federails/{application_controller.rb → server_controller.rb} +10 -3
  13. data/app/helpers/federails/server_helper.rb +12 -0
  14. data/app/models/concerns/federails/entity.rb +67 -15
  15. data/app/models/concerns/federails/has_uuid.rb +35 -0
  16. data/app/models/federails/activity.rb +8 -13
  17. data/app/models/federails/actor.rb +41 -2
  18. data/app/models/federails/following.rb +9 -0
  19. data/app/policies/federails/client/activity_policy.rb +3 -0
  20. data/app/policies/federails/client/actor_policy.rb +1 -1
  21. data/app/policies/federails/client/following_policy.rb +2 -2
  22. data/app/policies/federails/federails_policy.rb +4 -0
  23. data/app/policies/federails/server/activity_policy.rb +3 -0
  24. data/app/views/federails/client/activities/_activity.html.erb +1 -1
  25. data/app/views/federails/client/activities/feed.html.erb +8 -1
  26. data/app/views/federails/client/activities/index.html.erb +1 -1
  27. data/app/views/federails/client/actors/index.html.erb +14 -0
  28. data/app/views/federails/client/actors/show.html.erb +101 -89
  29. data/app/views/federails/client/common/_client_links.html.erb +24 -0
  30. data/app/views/federails/client/followings/_follow_actions.html.erb +32 -0
  31. data/app/views/federails/client/followings/_form.html.erb +1 -0
  32. data/app/views/federails/server/activities/{_activity.json.jbuilder → _activity.activitypub.jbuilder} +6 -1
  33. data/app/views/federails/server/actors/_actor.activitypub.jbuilder +26 -0
  34. data/app/views/federails/server/nodeinfo/{show.json.jbuilder → show.nodeinfo.jbuilder} +8 -7
  35. data/app/views/federails/server/web_finger/{find.json.jbuilder → find.jrd.jbuilder} +5 -1
  36. data/config/initializers/mime_types.rb +21 -0
  37. data/config/routes.rb +7 -3
  38. data/db/migrate/20200712133150_create_federails_actors.rb +3 -5
  39. data/db/migrate/20241002094500_add_uuids.rb +13 -0
  40. data/db/migrate/20241002094501_add_keypair_to_actors.rb +8 -0
  41. data/lib/federails/configuration.rb +11 -28
  42. data/lib/federails/version.rb +1 -1
  43. data/lib/federails.rb +13 -5
  44. data/lib/fediverse/inbox.rb +33 -37
  45. data/lib/fediverse/notifier.rb +44 -5
  46. data/lib/fediverse/signature.rb +49 -0
  47. data/lib/fediverse/webfinger.rb +31 -7
  48. data/lib/generators/federails/copy_client_views/USAGE +8 -0
  49. data/lib/generators/federails/copy_client_views/copy_client_views_generator.rb +9 -0
  50. data/lib/generators/federails/install/install_generator.rb +2 -2
  51. data/lib/generators/federails/install/templates/federails.yml +2 -0
  52. metadata +28 -20
  53. data/app/controllers/federails/server/server_controller.rb +0 -17
  54. data/app/helpers/federails/application_helper.rb +0 -4
  55. data/app/views/federails/server/actors/_actor.json.jbuilder +0 -11
  56. data/db/migrate/20240731145400_change_actor_entity_rel_to_polymorphic.rb +0 -11
  57. /data/app/views/federails/server/activities/{outbox.json.jbuilder → outbox.activitypub.jbuilder} +0 -0
  58. /data/app/views/federails/server/activities/{show.json.jbuilder → show.activitypub.jbuilder} +0 -0
  59. /data/app/views/federails/server/actors/{followers.json.jbuilder → followers.activitypub.jbuilder} +0 -0
  60. /data/app/views/federails/server/actors/{following.json.jbuilder → following.activitypub.jbuilder} +0 -0
  61. /data/app/views/federails/server/actors/{show.json.jbuilder → show.activitypub.jbuilder} +0 -0
  62. /data/app/views/federails/server/followings/{_following.json.jbuilder → _following.activitypub.jbuilder} +0 -0
  63. /data/app/views/federails/server/followings/{show.json.jbuilder → show.activitypub.jbuilder} +0 -0
  64. /data/app/views/federails/server/nodeinfo/{index.json.jbuilder → index.nodeinfo.jbuilder} +0 -0
  65. /data/app/views/federails/server/web_finger/{host_meta.xml.erb → host_meta.xrd.erb} +0 -0
@@ -2,34 +2,33 @@ require 'fediverse/request'
2
2
 
3
3
  module Fediverse
4
4
  class Inbox
5
+ @@handlers = {} # rubocop:todo Style/ClassVars
5
6
  class << self
7
+ def register_handler(activity_type, object_type, klass, method)
8
+ @@handlers[activity_type] ||= {}
9
+ @@handlers[activity_type][object_type] ||= {}
10
+ @@handlers[activity_type][object_type][klass] = method
11
+ end
12
+
6
13
  def dispatch_request(payload)
7
- case payload['type']
8
- when 'Create'
9
- handle_create_request payload
10
- when 'Follow'
11
- handle_create_follow_request payload
12
- when 'Accept'
13
- handle_accept_request payload
14
- when 'Undo'
15
- handle_undo_request payload
16
- else
17
- # FIXME: Fails silently
18
- # raise NotImplementedError
19
- Rails.logger.debug { "Unhandled activity type: #{payload['type']}" }
14
+ handlers = get_handlers(payload['type'], payload['object'].is_a?(Hash) ? payload.dig('object', 'type') : nil)
15
+ handlers.each_pair do |klass, method|
16
+ klass.send method, payload
20
17
  end
18
+ return unless handlers.empty?
19
+
20
+ # FIXME: Fails silently
21
+ # raise NotImplementedError
22
+ Rails.logger.debug { "Unhandled activity type: #{payload['type']}" }
21
23
  end
22
24
 
23
25
  private
24
26
 
25
- def handle_create_request(payload)
26
- activity = Request.get(payload['object'])
27
- case activity['type']
28
- when 'Follow'
29
- handle_create_follow_request activity
30
- when 'Note'
31
- handle_create_note activity
32
- end
27
+ def get_handlers(activity_type, object_type)
28
+ {}.merge(@@handlers.dig(activity_type, object_type) || {})
29
+ .merge(@@handlers.dig(activity_type, '*') || {})
30
+ .merge(@@handlers.dig('*', '*') || {})
31
+ .merge(@@handlers.dig('*', object_type) || {})
33
32
  end
34
33
 
35
34
  def handle_create_follow_request(activity)
@@ -39,33 +38,30 @@ module Fediverse
39
38
  Federails::Following.create! actor: actor, target_actor: target_actor, federated_url: activity['id']
40
39
  end
41
40
 
42
- def handle_create_note(activity)
43
- actor = Federails::Actor.find_or_create_by_object activity['attributedTo']
44
- Note.create! actor: actor, content: activity['content'], federated_url: activity['id']
45
- end
41
+ def handle_accept_request(activity)
42
+ original_activity = Request.get(activity['object'])
46
43
 
47
- def handle_accept_request(payload)
48
- activity = Request.get(payload['object'])
49
- raise "Can't accept things that are not Follow" unless activity['type'] == 'Follow'
50
-
51
- actor = Federails::Actor.find_or_create_by_object activity['actor']
52
- target_actor = Federails::Actor.find_or_create_by_object activity['object']
53
- raise 'Follow not accepted by target actor but by someone else' if payload['actor'] != target_actor.federated_url
44
+ actor = Federails::Actor.find_or_create_by_object original_activity['actor']
45
+ target_actor = Federails::Actor.find_or_create_by_object original_activity['object']
46
+ raise 'Follow not accepted by target actor but by someone else' if activity['actor'] != target_actor.federated_url
54
47
 
55
48
  follow = Federails::Following.find_by actor: actor, target_actor: target_actor
56
49
  follow.accept!
57
50
  end
58
51
 
59
- def handle_undo_request(payload)
60
- activity = payload['object']
61
- raise "Can't undo things that are not Follow" unless activity['type'] == 'Follow'
52
+ def handle_undo_request(activity)
53
+ original_activity = activity['object']
62
54
 
63
- actor = Federails::Actor.find_or_create_by_object activity['actor']
64
- target_actor = Federails::Actor.find_or_create_by_object activity['object']
55
+ actor = Federails::Actor.find_or_create_by_object original_activity['actor']
56
+ target_actor = Federails::Actor.find_or_create_by_object original_activity['object']
65
57
 
66
58
  follow = Federails::Following.find_by actor: actor, target_actor: target_actor
67
59
  follow&.destroy
68
60
  end
69
61
  end
62
+
63
+ register_handler 'Follow', '*', self, :handle_create_follow_request
64
+ register_handler 'Accept', 'Follow', self, :handle_accept_request
65
+ register_handler 'Undo', 'Follow', self, :handle_undo_request
70
66
  end
71
67
  end
@@ -1,21 +1,60 @@
1
+ require 'fediverse/signature'
2
+
1
3
  module Fediverse
2
4
  class Notifier
3
5
  class << self
4
6
  def post_to_inboxes(activity)
5
7
  actors = activity.recipients
6
-
7
8
  Rails.logger.debug('Nobody to notice') && return if actors.count.zero?
8
9
 
9
- message = Federails::ApplicationController.renderer.new.render(
10
+ message = payload(activity)
11
+ actors.each do |recipient|
12
+ Rails.logger.debug { "Sending activity ##{activity.id} to #{recipient.inbox_url}" }
13
+ post_to_inbox(to: recipient, message: message, from: activity.actor)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def payload(activity)
20
+ Federails::ServerController.renderer.new.render(
10
21
  template: 'federails/server/activities/show',
11
22
  assigns: { activity: activity },
12
23
  format: :json
13
24
  )
14
- actors.each do |actor|
15
- Rails.logger.debug { "Sending activity ##{activity.id} to #{actor.inbox_url}" }
16
- Faraday.post actor.inbox_url, message, 'Content-Type' => 'application/json', 'Accept' => 'application/json'
25
+ end
26
+
27
+ def post_to_inbox(to:, message:, from: nil)
28
+ conn = Faraday.default_connection
29
+ conn.builder.build_response(
30
+ conn,
31
+ signed_request(to: to, message: message, from: from)
32
+ )
33
+ end
34
+
35
+ def signed_request(to:, message:, from:)
36
+ req = request(to: to, message: message)
37
+ req.headers['Signature'] = Fediverse::Signature.sign(sender: from, request: req) if from
38
+ req
39
+ end
40
+
41
+ def request(to:, message:) # rubocop:todo Metrics/AbcSize
42
+ Faraday.default_connection.build_request(:post) do |req|
43
+ req.url to.inbox_url
44
+ req.body = message
45
+ req.headers['Content-Type'] = Mime[:activitypub].to_s
46
+ req.headers['Accept'] = Mime[:activitypub].to_s
47
+ req.headers['Host'] = URI.parse(to.inbox_url).host
48
+ req.headers['Date'] = Time.now.utc.httpdate
49
+ req.headers['Digest'] = digest(message)
17
50
  end
18
51
  end
52
+
53
+ def digest(message)
54
+ "SHA-256=#{Base64.strict_encode64(
55
+ OpenSSL::Digest.new('SHA256').digest(message)
56
+ )}"
57
+ end
19
58
  end
20
59
  end
21
60
  end
@@ -0,0 +1,49 @@
1
+ module Fediverse
2
+ class Signature
3
+ class << self
4
+ def sign(sender:, request:)
5
+ private_key = OpenSSL::PKey::RSA.new sender.private_key, Rails.application.credentials.secret_key_base
6
+ headers = '(request-target) host date digest'
7
+ sig = Base64.strict_encode64(
8
+ private_key.sign(
9
+ OpenSSL::Digest.new('SHA256'), signature_payload(request: request, headers: headers)
10
+ )
11
+ )
12
+ {
13
+ keyId: sender.key_id,
14
+ headers: headers,
15
+ signature: sig,
16
+ }.map { |k, v| "#{k}=\"#{v}\"" }.join(',')
17
+ end
18
+
19
+ def verify(sender:, request:)
20
+ raise 'Unsigned headers' unless request.headers['Signature']
21
+
22
+ signature_header = request.headers['Signature'].split(',').to_h do |pair|
23
+ /\A(?<key>[\w]+)="(?<value>.*)"\z/ =~ pair
24
+ [key, value]
25
+ end
26
+
27
+ headers = signature_header['headers']
28
+ signature = Base64.decode64(signature_header['signature'])
29
+ key = OpenSSL::PKey::RSA.new(sender.public_key)
30
+
31
+ comparison_string = signature_payload(request: request, headers: headers)
32
+
33
+ key.verify(OpenSSL::Digest.new('SHA256'), signature, comparison_string)
34
+ end
35
+
36
+ private
37
+
38
+ def signature_payload(request:, headers:)
39
+ headers.split.map do |signed_header_name|
40
+ if signed_header_name == '(request-target)'
41
+ "(request-target): #{request.http_method} #{URI.parse(request.path).path}"
42
+ else
43
+ "#{signed_header_name}: #{request.headers[signed_header_name.capitalize]}"
44
+ end
45
+ end.join("\n")
46
+ end
47
+ end
48
+ end
49
+ end
@@ -30,28 +30,52 @@ module Fediverse
30
30
 
31
31
  # Returns actor id
32
32
  def webfinger(username, domain)
33
- scheme = Federails.configuration.force_ssl ? 'https' : 'http'
34
- json = get_json "#{scheme}://#{domain}/.well-known/webfinger", resource: "acct:#{username}@#{domain}"
33
+ json = webfinger_response(username, domain)
35
34
  link = json['links'].find { |l| l['type'] == 'application/activity+json' }
36
35
 
37
36
  link['href'] if link
38
37
  end
39
38
 
39
+ # Returns remote follow link template, or complete link if actor_url is provided
40
+ def remote_follow_url(username, domain, actor_url: nil)
41
+ json = webfinger_response(username, domain)
42
+ link = json['links'].find { |l| l['rel'] == 'http://ostatus.org/schema/1.0/subscribe' }
43
+ return nil if link&.dig('template').nil?
44
+
45
+ if actor_url
46
+ link['template'].gsub('{uri}', CGI.escape(actor_url))
47
+ else
48
+ link['template']
49
+ end
50
+ end
51
+
40
52
  private
41
53
 
54
+ def webfinger_response(username, domain)
55
+ scheme = Federails.configuration.force_ssl ? 'https' : 'http'
56
+ get_json "#{scheme}://#{domain}/.well-known/webfinger", resource: "acct:#{username}@#{domain}"
57
+ end
58
+
59
+ def server_and_port(id)
60
+ uri = URI.parse id
61
+ if uri.port && [80, 443].exclude?(uri.port)
62
+ "#{uri.host}:#{uri.port}"
63
+ else
64
+ uri.host
65
+ end
66
+ end
67
+
42
68
  def webfinger_to_actor(data)
43
- uri = URI.parse data['id']
44
- server = uri.host
45
- server += ":#{uri.port}" if uri.port && [80, 443].exclude?(uri.port)
46
69
  Federails::Actor.new federated_url: data['id'],
47
70
  username: data['preferredUsername'],
48
71
  name: data['name'],
49
- server: server,
72
+ server: server_and_port(data['id']),
50
73
  inbox_url: data['inbox'],
51
74
  outbox_url: data['outbox'],
52
75
  followers_url: data['followers'],
53
76
  followings_url: data['following'],
54
- profile_url: data['url']
77
+ profile_url: data['url'],
78
+ public_key: data.dig('publicKey', 'publicKeyPem')
55
79
  end
56
80
 
57
81
  def get_json(url, payload = {})
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Copies the client views to be overridden in main application
3
+
4
+ Example:
5
+ bin/rails generate copy_client_views
6
+
7
+ This will create:
8
+ app/views/federails/client/**/*
@@ -0,0 +1,9 @@
1
+ module Federails
2
+ class CopyClientViewsGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../../../../app/views', __dir__)
4
+
5
+ def copy_views
6
+ directory 'federails/client', Rails.root.join('app', 'views', 'federails', 'client')
7
+ end
8
+ end
9
+ end
@@ -3,8 +3,8 @@ module Federails
3
3
  source_root File.expand_path('templates', __dir__)
4
4
 
5
5
  def copy_files
6
- copy_file 'federails.yml', 'config/federails.yml'
7
- copy_file 'federails.rb', 'config/initializers/federails.rb'
6
+ copy_file 'federails.yml', Rails.root.join('config', 'federails.yml')
7
+ copy_file 'federails.rb', Rails.root.join('config', 'initializers', 'federails.rb')
8
8
  end
9
9
  end
10
10
  end
@@ -6,9 +6,11 @@ defaults: &defaults
6
6
  site_host: http://localhost
7
7
  site_port: 3000
8
8
  enable_discovery: true
9
+ open_registrations: false
9
10
  app_layout: 'layouts/application'
10
11
  server_routes_path: federation
11
12
  client_routes_path: app
13
+ #base_client_controller: ::ActionController::Base
12
14
 
13
15
  development:
14
16
  <<: *defaults
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: federails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Tancoigne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-04 00:00:00.000000000 Z
11
+ date: 2024-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -119,21 +119,22 @@ files:
119
119
  - Rakefile
120
120
  - app/assets/config/federails_manifest.js
121
121
  - app/assets/stylesheets/federails/application.css
122
- - app/controllers/federails/application_controller.rb
123
122
  - app/controllers/federails/client/activities_controller.rb
124
123
  - app/controllers/federails/client/actors_controller.rb
125
124
  - app/controllers/federails/client/followings_controller.rb
125
+ - app/controllers/federails/client_controller.rb
126
126
  - app/controllers/federails/server/activities_controller.rb
127
127
  - app/controllers/federails/server/actors_controller.rb
128
128
  - app/controllers/federails/server/followings_controller.rb
129
129
  - app/controllers/federails/server/nodeinfo_controller.rb
130
- - app/controllers/federails/server/server_controller.rb
131
130
  - app/controllers/federails/server/web_finger_controller.rb
132
- - app/helpers/federails/application_helper.rb
131
+ - app/controllers/federails/server_controller.rb
132
+ - app/helpers/federails/server_helper.rb
133
133
  - app/jobs/federails/application_job.rb
134
134
  - app/jobs/federails/notify_inbox_job.rb
135
135
  - app/mailers/federails/application_mailer.rb
136
136
  - app/models/concerns/federails/entity.rb
137
+ - app/models/concerns/federails/has_uuid.rb
137
138
  - app/models/federails/activity.rb
138
139
  - app/models/federails/actor.rb
139
140
  - app/models/federails/application_record.rb
@@ -158,7 +159,9 @@ files:
158
159
  - app/views/federails/client/actors/index.json.jbuilder
159
160
  - app/views/federails/client/actors/show.html.erb
160
161
  - app/views/federails/client/actors/show.json.jbuilder
162
+ - app/views/federails/client/common/_client_links.html.erb
161
163
  - app/views/federails/client/followings/_follow.html.erb
164
+ - app/views/federails/client/followings/_follow_actions.html.erb
162
165
  - app/views/federails/client/followings/_follower.html.erb
163
166
  - app/views/federails/client/followings/_following.json.jbuilder
164
167
  - app/views/federails/client/followings/_form.html.erb
@@ -166,24 +169,26 @@ files:
166
169
  - app/views/federails/client/followings/index.json.jbuilder
167
170
  - app/views/federails/client/followings/show.html.erb
168
171
  - app/views/federails/client/followings/show.json.jbuilder
169
- - app/views/federails/server/activities/_activity.json.jbuilder
170
- - app/views/federails/server/activities/outbox.json.jbuilder
171
- - app/views/federails/server/activities/show.json.jbuilder
172
- - app/views/federails/server/actors/_actor.json.jbuilder
173
- - app/views/federails/server/actors/followers.json.jbuilder
174
- - app/views/federails/server/actors/following.json.jbuilder
175
- - app/views/federails/server/actors/show.json.jbuilder
176
- - app/views/federails/server/followings/_following.json.jbuilder
177
- - app/views/federails/server/followings/show.json.jbuilder
178
- - app/views/federails/server/nodeinfo/index.json.jbuilder
179
- - app/views/federails/server/nodeinfo/show.json.jbuilder
180
- - app/views/federails/server/web_finger/find.json.jbuilder
181
- - app/views/federails/server/web_finger/host_meta.xml.erb
172
+ - app/views/federails/server/activities/_activity.activitypub.jbuilder
173
+ - app/views/federails/server/activities/outbox.activitypub.jbuilder
174
+ - app/views/federails/server/activities/show.activitypub.jbuilder
175
+ - app/views/federails/server/actors/_actor.activitypub.jbuilder
176
+ - app/views/federails/server/actors/followers.activitypub.jbuilder
177
+ - app/views/federails/server/actors/following.activitypub.jbuilder
178
+ - app/views/federails/server/actors/show.activitypub.jbuilder
179
+ - app/views/federails/server/followings/_following.activitypub.jbuilder
180
+ - app/views/federails/server/followings/show.activitypub.jbuilder
181
+ - app/views/federails/server/nodeinfo/index.nodeinfo.jbuilder
182
+ - app/views/federails/server/nodeinfo/show.nodeinfo.jbuilder
183
+ - app/views/federails/server/web_finger/find.jrd.jbuilder
184
+ - app/views/federails/server/web_finger/host_meta.xrd.erb
185
+ - config/initializers/mime_types.rb
182
186
  - config/routes.rb
183
187
  - db/migrate/20200712133150_create_federails_actors.rb
184
188
  - db/migrate/20200712143127_create_federails_followings.rb
185
189
  - db/migrate/20200712174938_create_federails_activities.rb
186
- - db/migrate/20240731145400_change_actor_entity_rel_to_polymorphic.rb
190
+ - db/migrate/20241002094500_add_uuids.rb
191
+ - db/migrate/20241002094501_add_keypair_to_actors.rb
187
192
  - lib/federails.rb
188
193
  - lib/federails/configuration.rb
189
194
  - lib/federails/engine.rb
@@ -192,7 +197,10 @@ files:
192
197
  - lib/fediverse/inbox.rb
193
198
  - lib/fediverse/notifier.rb
194
199
  - lib/fediverse/request.rb
200
+ - lib/fediverse/signature.rb
195
201
  - lib/fediverse/webfinger.rb
202
+ - lib/generators/federails/copy_client_views/USAGE
203
+ - lib/generators/federails/copy_client_views/copy_client_views_generator.rb
196
204
  - lib/generators/federails/install/USAGE
197
205
  - lib/generators/federails/install/install_generator.rb
198
206
  - lib/generators/federails/install/templates/federails.rb
@@ -222,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
230
  - !ruby/object:Gem::Version
223
231
  version: '0'
224
232
  requirements: []
225
- rubygems_version: 3.4.15
233
+ rubygems_version: 3.3.7
226
234
  signing_key:
227
235
  specification_version: 4
228
236
  summary: An ActivityPub engine for Ruby on Rails
@@ -1,17 +0,0 @@
1
- module Federails
2
- module Server
3
- class ServerController < Federails::ApplicationController
4
- protect_from_forgery with: :null_session
5
-
6
- # def policy_scope(scope, policy_scope_class: nil)
7
- # scope = [scope, :server] unless policy_scope_class
8
- # super(scope, policy_scope_class: policy_scope_class)
9
- # end
10
-
11
- # def authorize(record, query = nil, policy_class: nil)
12
- # record = [:server, record] unless policy_class
13
- # super(record, query, policy_class: policy_class)
14
- # end
15
- end
16
- end
17
- end
@@ -1,4 +0,0 @@
1
- module Federails
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,11 +0,0 @@
1
- json.set! '@context', 'https://www.w3.org/ns/activitystreams'
2
-
3
- json.id actor.federated_url
4
- json.name actor.name
5
- json.type actor.entity_configuration[:actor_type]
6
- json.preferredUsername actor.username
7
- json.inbox actor.inbox_url
8
- json.outbox actor.outbox_url
9
- json.followers actor.followers_url
10
- json.following actor.followings_url
11
- json.url actor.profile_url
@@ -1,11 +0,0 @@
1
- class ChangeActorEntityRelToPolymorphic < ActiveRecord::Migration[7.0]
2
- def change
3
- remove_foreign_key :federails_actors, column: :user_id, to_table: Federails::Configuration.user_table
4
- remove_index :federails_actors, :user_id, unique: true
5
- change_table :federails_actors do |t|
6
- t.rename :user_id, :entity_id
7
- t.string :entity_type, null: true, default: Federails::Configuration.user_class&.demodulize
8
- t.index [:entity_type, :entity_id], name: 'index_federails_actors_on_entity', unique: true
9
- end
10
- end
11
- end