fix(instances): record the instance when refreshing known users too
Hosts without a row (IPv6 literals skipped by the backfill, rows deleted later) were never added again, because known users take the update path.
This commit is contained in:
parent
958166589e
commit
1849356abe
2 changed files with 15 additions and 5 deletions
|
|
@ -2058,6 +2058,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
def make_user_from_ap_id(ap_id, additional \\ []) do
|
||||
with {:ok, data} <- fetch_and_prepare_user_from_ap_id(ap_id, additional) do
|
||||
enqueue_pin_fetches(data)
|
||||
# Keeps the instances table complete, so it can list our peers.
|
||||
Instance.ensure_exists(data.ap_id)
|
||||
|
||||
# the fetched actor's id differs from ap_id when it was fetched from a display URL
|
||||
user = User.get_cached_by_ap_id(data.ap_id)
|
||||
|
|
@ -2069,11 +2071,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
else
|
||||
maybe_handle_clashing_nickname(data)
|
||||
|
||||
with {:ok, user} <- data |> User.remote_user_changeset() |> Repo.insert() do
|
||||
# Keeps the instances table complete, so it can list our peers.
|
||||
Instance.ensure_exists(user.ap_id)
|
||||
User.set_cache({:ok, user})
|
||||
end
|
||||
data
|
||||
|> User.remote_user_changeset()
|
||||
|> Repo.insert()
|
||||
|> User.set_cache()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -193,6 +193,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
Repo.get_by(Pleroma.Instances.Instance, host: "mastodon.example.org")
|
||||
end
|
||||
|
||||
test "it records the instance of a known user when refreshing it" do
|
||||
insert(:user, local: false, ap_id: "http://mastodon.example.org/users/admin")
|
||||
refute Repo.get_by(Pleroma.Instances.Instance, host: "mastodon.example.org")
|
||||
|
||||
{:ok, _user} = ActivityPub.make_user_from_ap_id("http://mastodon.example.org/users/admin")
|
||||
|
||||
assert Repo.get_by(Pleroma.Instances.Instance, host: "mastodon.example.org")
|
||||
end
|
||||
|
||||
test "it keeps an existing instance record" do
|
||||
unreachable_since = ~N[2020-01-01 00:00:00.000000]
|
||||
insert(:instance, host: "mastodon.example.org", unreachable_since: unreachable_since)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue