Update user reference after fetch

Since we always followed redirects (and until recently allowed fuzzy id
matches), the ap_id of the received object might differ from the iniital
fetch url. This lead to us mistakenly trying to insert a new user with
the same nickname, ap_id, etc as an existing user (which will fail due
to uniqueness constraints) instead of updating the existing one.
This commit is contained in:
Oneric 2024-03-20 19:03:39 -01:00
parent 9061d148be
commit 48b3a35793
1 changed files with 7 additions and 0 deletions

View File

@ -1840,6 +1840,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
with {:ok, data} <- fetch_and_prepare_user_from_ap_id(ap_id, additional) do
{:ok, _pid} = Task.start(fn -> pinned_fetch_task(data) end)
user =
if data.ap_id != ap_id do
User.get_cached_by_ap_id(data.ap_id)
else
user
end
if user do
user
|> User.remote_user_changeset(data)