fix last_outbox_fetch

This commit is contained in:
TudbuT 2024-11-03 23:50:42 +01:00
parent e37ffa1b1f
commit 718dae0f97
No known key found for this signature in database
GPG key ID: B3CF345217F202D3
3 changed files with 8 additions and 11 deletions

View file

@ -2771,9 +2771,11 @@ def accepts_direct_messages?(%User{accepts_direct_messages_from: :everybody}, _)
def accepts_direct_messages?(%User{accepts_direct_messages_from: :nobody}, _),
do: false
def outbox_refreshed(user) do
def outbox_refreshed(%User{} = user) do
#now = NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)
user
|> cast(%{last_outbox_fetch: DateTime.utc_now()}, [:last_outbox_fetch])
|> cast(%{last_outbox_fetch: NaiveDateTime.utc_now()}, [:last_outbox_fetch])
|> update_and_set_cache()
end
end

View file

@ -1867,16 +1867,11 @@ def enqueue_outbox_fetches(
0
else
last_fetch
|> DateTime.from_iso8601()
|> DateTime.to_unix()
end,
now <- DateTime.utc_now().to_unix(),
# future => epoch stuff, let it pass
# >60 secs in past => ok
# otherwise in timeout
now <-
NaiveDateTime.utc_now(),
{true} <-
{last_fetch > now ||
last_fetch < now - 60}
{last_fetch < NaiveDateTime.add(now, -60)}
) do
# enqueue a task to fetch the outbox
Logger.debug("Refetching outbox #{outbox_address}")

View file

@ -4,7 +4,7 @@ defmodule Pleroma.Repo.Migrations.UsersAddOutboxes do
def up do
alter table(:users) do
add_if_not_exists(:outbox, :text)
add_if_not_exists(:last_outbox_fetch, :text)
add_if_not_exists(:last_outbox_fetch, :naive_datetime)
end
end