handle empty last_fetch
Some checks are pending
ci/woodpecker/pr/build-amd64 Pipeline is pending approval
ci/woodpecker/pr/build-arm64 Pipeline is pending approval
ci/woodpecker/pr/docs Pipeline is pending approval
ci/woodpecker/pr/lint Pipeline is pending approval
ci/woodpecker/pr/test Pipeline is pending approval

This commit is contained in:
TudbuT 2024-11-03 23:11:19 +01:00
parent ee1f8938fc
commit 488d4b7c2e
No known key found for this signature in database
GPG key ID: B3CF345217F202D3
2 changed files with 8 additions and 3 deletions

View file

@ -211,14 +211,14 @@ defp log_fetch_error(id, error) do
end end
# if its already an activity, dont wrap # if its already an activity, dont wrap
defp prepare_activity_params(%{"object" => _ } = data), do: data defp prepare_activity_params(%{"object" => _} = data), do: data
defp prepare_activity_params(data) do defp prepare_activity_params(data) do
%{ %{
"type" => "Create", "type" => "Create",
# Should we seriously keep this attributedTo thing? # Should we seriously keep this attributedTo thing?
"actor" => data["actor"] || data["attributedTo"], "actor" => data["actor"] || data["attributedTo"],
"object" => data, "object" => data
} }
|> Maps.put_if_present("to", data["to"]) |> Maps.put_if_present("to", data["to"])
|> Maps.put_if_present("cc", data["cc"]) |> Maps.put_if_present("cc", data["cc"])

View file

@ -1862,7 +1862,12 @@ def enqueue_outbox_fetches(
%{outbox: outbox_address, last_outbox_fetch: last_fetch, local: false} = user %{outbox: outbox_address, last_outbox_fetch: last_fetch, local: false} = user
) do ) do
with( with(
last_fetch <- last_fetch.to_unix(), last_fetch <-
if last_fetch == nil do
0
else
last_fetch.to_unix()
end,
now <- DateTime.utc_now().to_unix(), now <- DateTime.utc_now().to_unix(),
# future => epoch stuff, let it pass # future => epoch stuff, let it pass
# >60 secs in past => ok # >60 secs in past => ok