Add patch for lazier user refreshes
This commit is contained in:
parent
9389bb6cdb
commit
f515c31462
2 changed files with 75 additions and 0 deletions
|
@ -29,6 +29,8 @@ up-2b1a252cc78dbb3ff8a34a8365b8c049c0b531fb_truncate-remote-user-fields.patch
|
|||
# Various perf tweaks related to statistic queries and job handling; also purge of ap_enabled.
|
||||
# dropped database load by about 20% on my small instance
|
||||
pr862_perftweak-stats-and-jobs.patch
|
||||
# WIP: after db pruning way too much stuff got refetched
|
||||
wip_less_aggressive_user_refresh.patch
|
||||
# Extra debugging
|
||||
dbg_log_receiver_crashes.patch
|
||||
dbg_log_all_http_requests.patch
|
||||
|
|
73
patches/wip_less_aggressive_user_refresh.patch
Normal file
73
patches/wip_less_aggressive_user_refresh.patch
Normal file
|
@ -0,0 +1,73 @@
|
|||
From 08972cec35195133f6d8e0c496a60abc17ae3951 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 ++-
|
||||
3 files changed, 11 insertions(+), 9 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
|
||||
--
|
||||
2.39.5
|
||||
|
Loading…
Reference in a new issue