87 lines
4 KiB
Diff
87 lines
4 KiB
Diff
From 95223da3d82f02ff904fcba8e0ba620491bb6c17 Mon Sep 17 00:00:00 2001
|
|
From: Oneric <oneric@oneric.stub>
|
|
Date: Sat, 28 Dec 2024 04:46:10 +0100
|
|
Subject: [PATCH] Be less aggressive about user refreshes
|
|
|
|
TODO: atm this still refreshes all users actually actively
|
|
sending stuff to the inbox, but this will change with the
|
|
signing key migration (only user/inbox endpoints still do)
|
|
---
|
|
lib/pleroma/user.ex | 15 ++++++++-------
|
|
lib/pleroma/web/activity_pub/object_validator.ex | 2 +-
|
|
.../article_note_page_validator.ex | 3 ++-
|
|
lib/pleroma/web/activity_pub/transmogrifier.ex | 2 +-
|
|
4 files changed, 12 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
|
|
index 697597e1b..41530871d 100644
|
|
--- a/lib/pleroma/user.ex
|
|
+++ b/lib/pleroma/user.ex
|
|
@@ -975,16 +975,17 @@ defp maybe_send_registration_email(%User{email: email} = user) when is_binary(em
|
|
|
|
defp maybe_send_registration_email(_), do: {:ok, :noop}
|
|
|
|
- def needs_update?(user, options \\ [])
|
|
- def needs_update?(%User{local: true}, _options), do: false
|
|
- def needs_update?(%User{local: false, last_refreshed_at: nil}, _options), do: true
|
|
+ defp needs_update?(user, options)
|
|
+ defp needs_update?(%User{local: true}, _options), do: false
|
|
+ defp needs_update?(%User{local: false, last_refreshed_at: nil}, _options), do: true
|
|
|
|
- def needs_update?(%User{local: false} = user, options) do
|
|
- NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >=
|
|
- Keyword.get(options, :maximum_age, 86_400)
|
|
+ defp needs_update?(%User{local: false} = user, options) do
|
|
+ Keyword.get(options, :update_existing, true) &&
|
|
+ NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >=
|
|
+ Keyword.get(options, :maximum_age, 86_400)
|
|
end
|
|
|
|
- def needs_update?(_, _options), do: true
|
|
+ defp needs_update?(_, _options), do: true
|
|
|
|
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
|
@spec can_direct_follow_local(User.t(), User.t()) :: true | false
|
|
diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex
|
|
index 93980f35b..084eb733c 100644
|
|
--- a/lib/pleroma/web/activity_pub/object_validator.ex
|
|
+++ b/lib/pleroma/web/activity_pub/object_validator.ex
|
|
@@ -249,7 +249,7 @@ def stringify_keys(object), do: object
|
|
def fetch_actor(object) do
|
|
with actor <- Containment.get_actor(object),
|
|
{:ok, actor} <- ObjectValidators.ObjectID.cast(actor) do
|
|
- User.get_or_fetch_by_ap_id(actor)
|
|
+ User.get_or_fetch_by_ap_id(actor, update_existing: false)
|
|
end
|
|
end
|
|
|
|
diff --git a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
|
|
index d1cd496db..b8ea6acd9 100644
|
|
--- a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
|
|
+++ b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
|
|
@@ -104,7 +104,8 @@ defp remote_mention_resolver(
|
|
(t["name"] == mention || mention == "#{t["name"]}@#{initial_host}")
|
|
end),
|
|
false <- is_nil(mention_tag),
|
|
- {:ok, %User{} = user} <- User.get_or_fetch_by_ap_id(mention_tag["href"]) do
|
|
+ {:ok, %User{} = user} <-
|
|
+ User.get_or_fetch_by_ap_id(mention_tag["href"], update_existing: false) do
|
|
link = Pleroma.Formatter.mention_tag(user, nickname, opts)
|
|
{link, %{acc | mentions: MapSet.put(acc.mentions, {"@" <> nickname, user})}}
|
|
else
|
|
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
|
|
index 142073fc6..9d82b1b73 100644
|
|
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
|
|
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
|
|
@@ -130,7 +130,7 @@ def fix_addressing(object) do
|
|
{:ok, %User{follower_address: follower_collection}} =
|
|
object
|
|
|> Containment.get_actor()
|
|
- |> User.get_or_fetch_by_ap_id()
|
|
+ |> User.get_or_fetch_by_ap_id(update_existing: false)
|
|
|
|
object
|
|
|> fix_addressing_list_key("to")
|
|
--
|
|
2.39.5
|
|
|