fedipub 0.9.0 → 0.11.0
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/README.md +7 -1
- data/app/controllers/concerns/fedipub/rails/server/render_collections.rb +21 -0
- data/app/controllers/fedipub/rails/client/activities_controller.rb +29 -0
- data/app/controllers/fedipub/rails/client/actors_controller.rb +56 -0
- data/app/controllers/fedipub/rails/client/followings_controller.rb +105 -0
- data/app/controllers/fedipub/rails/client_controller.rb +11 -0
- data/app/controllers/fedipub/rails/server/activities_controller.rb +80 -0
- data/app/controllers/fedipub/rails/server/actors_controller.rb +52 -0
- data/app/controllers/fedipub/rails/server/approval_stamps_controller.rb +15 -0
- data/app/controllers/fedipub/rails/server/followings_controller.rb +21 -0
- data/app/controllers/fedipub/rails/server/nodeinfo_controller.rb +30 -0
- data/app/controllers/fedipub/rails/server/published_controller.rb +32 -0
- data/app/controllers/fedipub/rails/server/web_finger_controller.rb +46 -0
- data/app/controllers/fedipub/rails/server_controller.rb +48 -0
- data/app/helpers/fedipub/rails/server_helper.rb +16 -0
- data/app/jobs/fedipub/application_job.rb +1 -1
- data/app/models/concerns/fedipub/actor_entity.rb +1 -125
- data/app/models/concerns/fedipub/data_entity.rb +5 -105
- data/app/models/fedipub/activity.rb +1 -0
- data/app/models/fedipub/actor.rb +28 -22
- data/app/models/fedipub/approval_stamp.rb +38 -0
- data/app/models/fedipub/host.rb +2 -2
- data/app/policies/fedipub/server/approval_stamp_policy.rb +9 -0
- data/app/views/fedipub/rails/client/activities/_index.json.jbuilder +1 -0
- data/app/views/fedipub/rails/client/activities/feed.json.jbuilder +1 -0
- data/app/views/fedipub/rails/client/activities/index.json.jbuilder +1 -0
- data/app/views/fedipub/{client → rails/client}/actors/_actor.json.jbuilder +1 -0
- data/app/views/fedipub/rails/client/actors/index.json.jbuilder +1 -0
- data/app/views/fedipub/{client → rails/client}/actors/show.html.erb +10 -5
- data/app/views/fedipub/rails/client/actors/show.json.jbuilder +1 -0
- data/app/views/fedipub/rails/client/followings/index.json.jbuilder +1 -0
- data/app/views/fedipub/rails/client/followings/show.json.jbuilder +1 -0
- data/app/views/fedipub/{server → rails/server}/activities/_activity.activitypub.jbuilder +2 -2
- data/app/views/fedipub/rails/server/activities/show.activitypub.jbuilder +1 -0
- data/app/views/fedipub/{server → rails/server}/actors/_actor.activitypub.jbuilder +14 -7
- data/app/views/fedipub/{server → rails/server}/actors/_tombstone.activitypub.jbuilder +1 -1
- data/app/views/fedipub/rails/server/actors/show.activitypub.jbuilder +5 -0
- data/app/views/fedipub/rails/server/approval_stamps/show.activitypub.jbuilder +8 -0
- data/app/views/fedipub/{server → rails/server}/followings/_following.activitypub.jbuilder +1 -1
- data/app/views/fedipub/rails/server/followings/show.activitypub.jbuilder +1 -0
- data/app/views/fedipub/rails/server/nodeinfo/index.nodeinfo.jbuilder +10 -0
- data/app/views/fedipub/rails/server/published/_publishable.activitypub.jbuilder +20 -0
- data/app/views/fedipub/{server → rails/server}/published/_tombstone.activitypub.jbuilder +1 -1
- data/app/views/fedipub/rails/server/published/show.activitypub.jbuilder +5 -0
- data/app/views/fedipub/{server → rails/server}/shared/ordered_collection.activitypub.jbuilder +1 -1
- data/app/views/fedipub/{server → rails/server}/shared/ordered_collection_page.activitypub.jbuilder +1 -1
- data/app/views/fedipub/{server → rails/server}/web_finger/find.jrd.jbuilder +11 -3
- data/config/initializers/logger.rb +2 -0
- data/config/initializers/miscellany.rb +21 -0
- data/config/initializers/security_vocab.rb +1 -0
- data/config/routes.rb +8 -7
- data/db/migrate/20260922155524_create_fedipub_approval_stamps.rb +12 -0
- data/db/migrate/20260924090802_add_shared_inbox_url_to_fedipub_actors.rb +5 -0
- data/lib/fedipub/activity_handlers/accept_follow_handler.rb +17 -0
- data/lib/fedipub/activity_handlers/delete_handler.rb +13 -0
- data/lib/fedipub/activity_handlers/follow_handler.rb +13 -0
- data/lib/fedipub/activity_handlers/quote_request_handler.rb +33 -0
- data/lib/fedipub/activity_handlers/undo_delete_handler.rb +15 -0
- data/lib/fedipub/activity_handlers/undo_follow_handler.rb +16 -0
- data/lib/fedipub/concerns/announceable.rb +23 -0
- data/lib/fedipub/concerns/application_actor.rb +30 -0
- data/lib/fedipub/concerns/generic_actor_entity.rb +135 -0
- data/lib/fedipub/concerns/generic_data_entity.rb +112 -0
- data/lib/fedipub/concerns/handles_delete_requests.rb +42 -0
- data/lib/fedipub/concerns/has_interaction_policy.rb +85 -0
- data/lib/fedipub/concerns/likeable.rb +34 -0
- data/lib/fedipub/concerns/quote_request.rb +42 -0
- data/lib/fedipub/data_transformer/note.rb +3 -2
- data/lib/fedipub/errors.rb +10 -0
- data/lib/fedipub/features.rb +13 -0
- data/lib/fedipub/logger.rb +42 -0
- data/lib/fedipub/utils/context.rb +30 -5
- data/lib/fedipub/utils/host.rb +1 -1
- data/lib/fedipub/utils/json_request.rb +63 -17
- data/lib/fedipub/utils/object.rb +1 -1
- data/lib/fedipub/version.rb +1 -1
- data/lib/fedipub.rb +14 -1
- data/lib/fediverse/collection.rb +1 -5
- data/lib/fediverse/inbox.rb +16 -51
- data/lib/fediverse/node_info.rb +2 -5
- data/lib/fediverse/notifier.rb +12 -39
- data/lib/fediverse/signature/draft_cavage12.rb +109 -0
- data/lib/fediverse/signature/rfc9421.rb +69 -0
- data/lib/fediverse/signature.rb +14 -39
- data/lib/fediverse/webfinger.rb +19 -18
- data/lib/generators/fedipub/copy_client_policies/USAGE +1 -1
- data/lib/generators/fedipub/copy_client_policies/copy_client_policies_generator.rb +2 -2
- data/lib/generators/fedipub/copy_client_views/USAGE +1 -1
- data/lib/generators/fedipub/copy_client_views/copy_client_views_generator.rb +2 -2
- data/lib/generators/fedipub/copy_factories/copy_factories_generator.rb +2 -2
- data/lib/generators/fedipub/install/install_generator.rb +3 -3
- metadata +109 -61
- data/app/assets/config/fedipub_manifest.js +0 -1
- data/app/assets/stylesheets/fedipub/application.css +0 -15
- data/app/controllers/concerns/fedipub/server/render_collections.rb +0 -19
- data/app/controllers/fedipub/client/activities_controller.rb +0 -27
- data/app/controllers/fedipub/client/actors_controller.rb +0 -54
- data/app/controllers/fedipub/client/followings_controller.rb +0 -103
- data/app/controllers/fedipub/client_controller.rb +0 -9
- data/app/controllers/fedipub/server/activities_controller.rb +0 -78
- data/app/controllers/fedipub/server/actors_controller.rb +0 -50
- data/app/controllers/fedipub/server/followings_controller.rb +0 -19
- data/app/controllers/fedipub/server/nodeinfo_controller.rb +0 -28
- data/app/controllers/fedipub/server/published_controller.rb +0 -30
- data/app/controllers/fedipub/server/web_finger_controller.rb +0 -45
- data/app/controllers/fedipub/server_controller.rb +0 -37
- data/app/helpers/fedipub/server_helper.rb +0 -18
- data/app/mailers/fedipub/application_mailer.rb +0 -6
- data/app/models/concerns/fedipub/announceable.rb +0 -18
- data/app/models/concerns/fedipub/handles_delete_requests.rb +0 -36
- data/app/models/concerns/fedipub/likeable.rb +0 -29
- data/app/views/fedipub/client/activities/_index.json.jbuilder +0 -1
- data/app/views/fedipub/client/activities/feed.json.jbuilder +0 -1
- data/app/views/fedipub/client/activities/index.json.jbuilder +0 -1
- data/app/views/fedipub/client/actors/index.json.jbuilder +0 -1
- data/app/views/fedipub/client/actors/show.json.jbuilder +0 -1
- data/app/views/fedipub/client/followings/index.json.jbuilder +0 -1
- data/app/views/fedipub/client/followings/show.json.jbuilder +0 -1
- data/app/views/fedipub/server/activities/show.activitypub.jbuilder +0 -1
- data/app/views/fedipub/server/actors/show.activitypub.jbuilder +0 -5
- data/app/views/fedipub/server/followings/show.activitypub.jbuilder +0 -1
- data/app/views/fedipub/server/nodeinfo/index.nodeinfo.jbuilder +0 -6
- data/app/views/fedipub/server/published/_publishable.activitypub.jbuilder +0 -11
- data/app/views/fedipub/server/published/show.activitypub.jbuilder +0 -5
- data/app/views/users/show.html.erb +0 -4
- /data/app/views/fedipub/{client → rails/client}/activities/_activity.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/activities/_activity.json.jbuilder +0 -0
- /data/app/views/fedipub/{client → rails/client}/activities/feed.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/activities/index.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/actors/_lookup_form.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/actors/gone.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/actors/index.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/common/_client_links.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/_follow.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/_follow_actions.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/_follower.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/_following.json.jbuilder +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/_form.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/index.html.erb +0 -0
- /data/app/views/fedipub/{client → rails/client}/followings/show.html.erb +0 -0
- /data/app/views/fedipub/{server → rails/server}/nodeinfo/show.nodeinfo.jbuilder +0 -0
- /data/app/views/fedipub/{server → rails/server}/web_finger/host_meta.xrd.erb +0 -0
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module Fedipub
|
|
2
|
-
module Server
|
|
3
|
-
# Controller to render ActivityPub representation of entities configured with Fedipub::DataEntity
|
|
4
|
-
class PublishedController < Fedipub::ServerController
|
|
5
|
-
def show
|
|
6
|
-
@publishable = type_scope.find_untombstoned_by!(url_param => params[:id])
|
|
7
|
-
authorize @publishable, policy_class: Fedipub::Server::PublishablePolicy
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def publishable_config
|
|
13
|
-
return @publishable_config if instance_variable_defined? :@publishable_config
|
|
14
|
-
|
|
15
|
-
_, @publishable_config = Fedipub.configuration.data_types.find { |_, v| v[:route_path_segment].to_s == params[:publishable_type] }
|
|
16
|
-
raise ActiveRecord::RecordNotFound, "Invalid #{params[:publishable_type]} type" unless @publishable_config
|
|
17
|
-
|
|
18
|
-
@publishable_config
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def url_param
|
|
22
|
-
publishable_config[:url_param]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def type_scope
|
|
26
|
-
publishable_config[:class].all
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'fediverse/webfinger'
|
|
2
|
-
|
|
3
|
-
module Fedipub
|
|
4
|
-
module Server
|
|
5
|
-
class WebFingerController < Fedipub::ServerController
|
|
6
|
-
def find
|
|
7
|
-
skip_authorization
|
|
8
|
-
|
|
9
|
-
resource = params.require(:resource)
|
|
10
|
-
case resource
|
|
11
|
-
when %r{^https?://.+}
|
|
12
|
-
@user = Fedipub::Actor.find_by_federation_url!(resource).entity # rubocop:disable Rails/DynamicFindBy
|
|
13
|
-
when /^acct:.+/
|
|
14
|
-
actor = Fedipub::Actor.find_local_by_username(username)
|
|
15
|
-
raise Fedipub::Actor::TombstonedError if actor&.tombstoned?
|
|
16
|
-
|
|
17
|
-
@user = actor&.entity
|
|
18
|
-
end
|
|
19
|
-
raise ActiveRecord::RecordNotFound if @user.nil?
|
|
20
|
-
|
|
21
|
-
render formats: [:jrd]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def host_meta
|
|
25
|
-
skip_authorization
|
|
26
|
-
|
|
27
|
-
render formats: [:xrd]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# TODO: complete missing endpoints
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def username
|
|
35
|
-
return @username if instance_variable_defined? :@username
|
|
36
|
-
|
|
37
|
-
account = Fediverse::Webfinger.split_account params.require(:resource)
|
|
38
|
-
# Fail early if user don't _seems_ local
|
|
39
|
-
raise ActiveRecord::RecordNotFound unless account && Fediverse::Webfinger.local_user?(account)
|
|
40
|
-
|
|
41
|
-
@username = account[:username]
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module Fedipub
|
|
2
|
-
class ServerController < ::ActionController::Base # rubocop:disable Rails/ApplicationController
|
|
3
|
-
include Pundit::Authorization
|
|
4
|
-
|
|
5
|
-
after_action :verify_authorized
|
|
6
|
-
|
|
7
|
-
protect_from_forgery with: :null_session
|
|
8
|
-
helper Fedipub::ServerHelper
|
|
9
|
-
|
|
10
|
-
rescue_from ActiveRecord::RecordNotFound, with: :error_not_found
|
|
11
|
-
rescue_from Fedipub::Actor::TombstonedError,
|
|
12
|
-
Fedipub::DataEntity::TombstonedError,
|
|
13
|
-
with: :error_gone
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
def error_fallback(exception, fallback_message, status)
|
|
18
|
-
message = exception&.message || fallback_message
|
|
19
|
-
respond_to do |format|
|
|
20
|
-
format.jrd { head status }
|
|
21
|
-
format.xrd { head status }
|
|
22
|
-
format.activitypub { head status }
|
|
23
|
-
format.nodeinfo { head status }
|
|
24
|
-
format.json { render json: { error: message }, status: status }
|
|
25
|
-
format.html { raise exception }
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def error_not_found(exception = nil)
|
|
30
|
-
error_fallback(exception, 'Resource not found', :not_found)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def error_gone(exception = nil)
|
|
34
|
-
error_fallback(exception, 'Resource is gone', :gone)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'fedipub/utils/context'
|
|
2
|
-
|
|
3
|
-
module Fedipub
|
|
4
|
-
module ServerHelper
|
|
5
|
-
def remote_follow_url
|
|
6
|
-
method_name = Fedipub.configuration.remote_follow_url_method.to_s
|
|
7
|
-
if method_name.starts_with? 'fedipub.'
|
|
8
|
-
send(method_name.gsub('fedipub.', ''))
|
|
9
|
-
else
|
|
10
|
-
Rails.application.routes.url_helpers.send(method_name)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def set_json_ld_context(json, additional: nil)
|
|
15
|
-
json.set! '@context', Fedipub::Utils::Context.generate(additional: additional)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module Fedipub
|
|
2
|
-
module Announceable
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
# Announces (boosts) this entity by creating a new Activity.
|
|
6
|
-
#
|
|
7
|
-
# @param actor [Fedipub::Actor] The actor doing the announce; defaults to the entity's own actor.
|
|
8
|
-
#
|
|
9
|
-
# @return [Fedipub::Activity] the newly-created Announce activity
|
|
10
|
-
def announce!(actor: nil)
|
|
11
|
-
actor ||= try(:fedipub_actor) || self
|
|
12
|
-
create_fedipub_activity('Announce',
|
|
13
|
-
actor: actor,
|
|
14
|
-
to: [Fediverse::Collection::PUBLIC],
|
|
15
|
-
cc: [actor.followers_url])
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module Fedipub
|
|
2
|
-
# Model concern providing hooks for on_fedipub_delete_requested callback
|
|
3
|
-
#
|
|
4
|
-
# ```rb
|
|
5
|
-
# # Example migration
|
|
6
|
-
# add_column :my_table, :uuid, :text, default: nil, index: { unique: true }
|
|
7
|
-
# ```
|
|
8
|
-
#
|
|
9
|
-
# Usage:
|
|
10
|
-
#
|
|
11
|
-
# ```rb
|
|
12
|
-
# class MyModel < ApplicationRecord
|
|
13
|
-
# include Fedipub::HandlesDeleteRequests
|
|
14
|
-
#
|
|
15
|
-
# on_fedipub_delete_requested -> { delete! }
|
|
16
|
-
# end
|
|
17
|
-
module HandlesDeleteRequests
|
|
18
|
-
extend ActiveSupport::Concern
|
|
19
|
-
|
|
20
|
-
# Class methods automatically included in the concern.
|
|
21
|
-
module ClassMethods
|
|
22
|
-
def on_fedipub_delete_requested(*)
|
|
23
|
-
set_callback(:on_fedipub_delete_requested, *)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def on_fedipub_undelete_requested(*)
|
|
27
|
-
set_callback(:on_fedipub_undelete_requested, *)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
included do
|
|
32
|
-
define_callbacks :on_fedipub_delete_requested
|
|
33
|
-
define_callbacks :on_fedipub_undelete_requested
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Fedipub
|
|
2
|
-
module Likeable
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
# Likes this entity by creating a new Activity.
|
|
6
|
-
#
|
|
7
|
-
# @param actor [Fedipub::Actor] The actor that is doing the liking.
|
|
8
|
-
#
|
|
9
|
-
# @return [Fedipub::Activity] the newly-created Like activity
|
|
10
|
-
def like!(actor:)
|
|
11
|
-
create_fedipub_activity('Like',
|
|
12
|
-
actor: actor,
|
|
13
|
-
to: [Fediverse::Collection::PUBLIC],
|
|
14
|
-
cc: [actor.followers_url])
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Dislikes this entity by creating a new Activity.
|
|
18
|
-
#
|
|
19
|
-
# @param actor [Fedipub::Actor] The actor that is doing the disliking.
|
|
20
|
-
#
|
|
21
|
-
# @return [Fedipub::Activity] the newly-created Dislike activity
|
|
22
|
-
def dislike!(actor:)
|
|
23
|
-
create_fedipub_activity('Dislike',
|
|
24
|
-
actor: actor,
|
|
25
|
-
to: [Fediverse::Collection::PUBLIC],
|
|
26
|
-
cc: [actor.followers_url])
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.array! @activities, partial: 'fedipub/client/activities/activity', as: :activity
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.partial! 'fedipub/client/activities/index'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.partial! 'fedipub/client/activities/index'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.array! @actors, partial: 'fedipub/client/actors/actor', as: :actor
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.partial! 'fedipub/client/actors/actor', actor: @actor
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.array! @followings, partial: 'fedipub/client/followings/following', as: :following
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.partial! 'fedipub/client/followings/following', following: @following
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.partial! 'fedipub/server/activities/activity', activity: @activity
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
json.partial! 'fedipub/server/followings/following', following: @following
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
context = true unless context == false
|
|
2
|
-
set_json_ld_context(json) if context
|
|
3
|
-
|
|
4
|
-
publishable.to_activitypub_object.each_pair do |key, value|
|
|
5
|
-
json.set! key, value
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
json.id publishable.federated_url
|
|
9
|
-
json.actor publishable.fedipub_actor.federated_url
|
|
10
|
-
json.to [Fediverse::Collection::PUBLIC]
|
|
11
|
-
json.cc [publishable.fedipub_actor.followers_url]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|