Skip refetching poll results if the object's updated_at is newer than the poll closed timestamp

This commit is contained in:
Mark Felder 2024-09-30 14:02:41 -04:00
parent c077a14ce1
commit 4b3f604f95

View file

@ -32,6 +32,8 @@ defmodule Pleroma.Workers.PollWorker do
def perform(%Job{args: %{"op" => "refresh", "activity_id" => activity_id}}) do
with {_, %Activity{object: object}} <-
{:activity, Activity.get_by_id_with_object(activity_id)},
{:ok, naive_closed} <- NaiveDateTime.from_iso8601(object.data["closed"]),
{_, :lt} <- {:closed_compare, NaiveDateTime.compare(object.updated_at, naive_closed)},
{_, {:ok, _object}} <- {:refetch, Fetcher.refetch_object(object)} do
stream_update(activity_id)
@ -39,6 +41,7 @@ defmodule Pleroma.Workers.PollWorker do
else
{:activity, nil} -> {:cancel, :poll_activity_not_found}
{:refetch, _} = e -> {:cancel, e}
{:closed_compare, _} -> {:cancel, :poll_finalized}
e -> {:error, e}
end
end