forked from AkkomaGang/akkoma
fix last_outbox_fetch
This commit is contained in:
parent
e37ffa1b1f
commit
718dae0f97
3 changed files with 8 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue