mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Remove unnecessary forced refresh of user
This commit is contained in:
parent
1b5964979f
commit
97cf78f63d
1 changed files with 4 additions and 16 deletions
|
@ -1037,16 +1037,6 @@ defmodule Pleroma.User do
|
||||||
|
|
||||||
defp maybe_send_registration_email(_), do: {:ok, :noop}
|
defp maybe_send_registration_email(_), do: {:ok, :noop}
|
||||||
|
|
||||||
def needs_update?(%User{local: true}), do: false
|
|
||||||
|
|
||||||
def needs_update?(%User{local: false, last_refreshed_at: nil}), do: true
|
|
||||||
|
|
||||||
def needs_update?(%User{local: false} = user) do
|
|
||||||
NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >= 86_400
|
|
||||||
end
|
|
||||||
|
|
||||||
def needs_update?(_), do: true
|
|
||||||
|
|
||||||
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
|
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
|
||||||
|
|
||||||
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
||||||
|
@ -2059,15 +2049,13 @@ defmodule Pleroma.User do
|
||||||
def fetch_by_ap_id(ap_id), do: ActivityPub.make_user_from_ap_id(ap_id)
|
def fetch_by_ap_id(ap_id), do: ActivityPub.make_user_from_ap_id(ap_id)
|
||||||
|
|
||||||
def get_or_fetch_by_ap_id(ap_id) do
|
def get_or_fetch_by_ap_id(ap_id) do
|
||||||
cached_user = get_cached_by_ap_id(ap_id)
|
user = get_cached_by_ap_id(ap_id) || fetch_by_ap_id(ap_id)
|
||||||
|
|
||||||
maybe_fetched_user = needs_update?(cached_user) && fetch_by_ap_id(ap_id)
|
case user do
|
||||||
|
%User{} = user ->
|
||||||
case {cached_user, maybe_fetched_user} do
|
|
||||||
{_, {:ok, %User{} = user}} ->
|
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
|
|
||||||
{%User{} = user, _} ->
|
{:ok, %User{} = user} ->
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
|
|
Loading…
Reference in a new issue