
CUrrently internal actors are supposed to be identified in the database by either a NULL nickname or a nickname prefixed by "internal.". For old installations this is true, but only if they were created over five years ago before70410dfafd
. Newer installations will use "relay" as the nickname of the realy actor causing ii to be treated as a regular user. In particular this means all installations in the last five years never made use of the reduced endpoint case, thus it is dropped. Simplify this distinction by properly marking internal actors asa an Application type in the database. This was already implemented before by ilja in https://akkoma.dev/AkkomaGang/akkoma/pulls/457 but accidentally reverted during a translation update ineba3cce77b
. This commit effectively restores this patch together with further changes. Also service actors unconditionally expose follow* collections atm, eventhough the internal fetch actor doesn't actually implement them. Since they are optional per spec and with Mastodon omitting them too for its instance actor proving the practical viability, we should just omit them. The relay actor however should continue to expose such collections and they are properly implemented here. Here too we now just use the values or their absence in the database. We do not have any other internal.* actors besides fetch atm. Fixes: https://akkoma.dev/AkkomaGang/akkoma/issues/855 Co-authored-by: ilja space <git@ilja.space>
41 lines
1.4 KiB
Elixir
41 lines
1.4 KiB
Elixir
defmodule Pleroma.Repo.Migrations.InstanceActorsTweaks do
|
||
use Ecto.Migration
|
||
|
||
import Ecto.Query
|
||
|
||
def up() do
|
||
# since Akkoma isn’t up and running at this point, Web.endpoint()
|
||
# isn’t available and we can't use the functions from Relay and InternalFetchActor,
|
||
# thus the AP ID suffix are hardcoded here and used together with a check for locality
|
||
# (e.g. custom ports make it hard to hardcode the full base url)
|
||
relay_ap_id = "%/relay"
|
||
fetch_ap_id = "%/internal/fetch"
|
||
|
||
# Convert to Application type
|
||
Pleroma.User
|
||
|> where([u], u.local and (like(u.ap_id, ^fetch_ap_id) or like(u.ap_id, ^relay_ap_id)))
|
||
|> Pleroma.Repo.update_all(set: [actor_type: "Application"])
|
||
|
||
# Drop bogus follow* addresses
|
||
Pleroma.User
|
||
|> where([u], u.local and like(u.ap_id, ^fetch_ap_id))
|
||
|> Pleroma.Repo.update_all(set: [follower_address: nil, following_address: nil])
|
||
|
||
# Add required follow* addresses
|
||
Pleroma.User
|
||
|> where([u], u.local and like(u.ap_id, ^relay_ap_id))
|
||
|> update([u],
|
||
set: [
|
||
follower_address: fragment("CONCAT(?, '/followers')", u.ap_id),
|
||
following_address: fragment("CONCAT(?, '/following')", u.ap_id)
|
||
]
|
||
)
|
||
|> Pleroma.Repo.update_all([])
|
||
end
|
||
|
||
def down do
|
||
# We don't know if the type was Person or Application before and
|
||
# without this or the lost patch it didn't matter, so just do nothing
|
||
:ok
|
||
end
|
||
end
|