From b71db2f82d91a6ae1406658374f15d948d8ad7e3 Mon Sep 17 00:00:00 2001 From: ilja Date: Sat, 4 Feb 2023 20:53:23 +0000 Subject: [PATCH] create_service_actor is now type Application This is used for internal fetch and for relay. Both represent the instance and therefore are an aplication. --- CHANGELOG.md | 1 + lib/pleroma/user.ex | 1 + ...tance_actors_to_actor_type_application.exs | 21 +++++++++++++++++++ test/pleroma/web/activity_pub/relay_test.exs | 6 ++++++ 4 files changed, 29 insertions(+) create mode 100644 priv/repo/migrations/20230202154409_instance_actors_to_actor_type_application.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index e6effac78..d66959efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Rich media will now hard-exit after 5 seconds, to prevent timeline hangs - HTTP Content Security Policy is now far more strict to prevent any potential XSS/CSS leakages - Follow requests are now paginated, matches mastodon API spec, so use the Link header to paginate. +- `internal.fetch` and `relay` actors are now represented with the actor type `Application` ### Fixed - /api/v1/accounts/lookup will now respect restrict\_unauthenticated diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 1572a895e..7a1e5628e 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -2000,6 +2000,7 @@ defp create_service_actor(uri, nickname) do %User{ invisible: true, local: true, + actor_type: "Application", ap_id: uri, nickname: nickname, follower_address: uri <> "/followers" diff --git a/priv/repo/migrations/20230202154409_instance_actors_to_actor_type_application.exs b/priv/repo/migrations/20230202154409_instance_actors_to_actor_type_application.exs new file mode 100644 index 000000000..5bf10704a --- /dev/null +++ b/priv/repo/migrations/20230202154409_instance_actors_to_actor_type_application.exs @@ -0,0 +1,21 @@ +defmodule Pleroma.Repo.Migrations.InstanceActorsToActorTypeApplication do + use Ecto.Migration + + def up do + execute(""" + update users + set actor_type = 'Application' + where local + and (ap_id like '%/relay' or ap_id like '%/internal/fetch') + """) + end + + def down do + execute(""" + update users + set actor_type = 'Person' + where local + and (ap_id like '%/relay' or ap_id like '%/internal/fetch') + """) + end +end diff --git a/test/pleroma/web/activity_pub/relay_test.exs b/test/pleroma/web/activity_pub/relay_test.exs index d6de7d61e..0bbfc316b 100644 --- a/test/pleroma/web/activity_pub/relay_test.exs +++ b/test/pleroma/web/activity_pub/relay_test.exs @@ -19,6 +19,12 @@ test "gets an actor for the relay" do assert user.ap_id == "#{Pleroma.Web.Endpoint.url()}/relay" end + test "relay actor is an application" do + # See + user = Relay.get_actor() + assert user.actor_type == "Application" + end + test "relay actor is invisible" do user = Relay.get_actor() assert User.invisible?(user)