Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85828146
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index a5325d8ec..f6c74bdac 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -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
diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs
index fcebdffb1..bd7c97820 100644
--- a/test/pleroma/web/activity_pub/activity_pub_test.exs
+++ b/test/pleroma/web/activity_pub/activity_pub_test.exs
@@ -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)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 31, 3:15 AM (20 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1800961
Default Alt Text
(2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline