From 6a6e42c9bfe7e381cb72d685bd982e55edcf5d38 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 18 Jul 2021 10:49:35 -0500 Subject: [PATCH] PollWorker defensive checks --- lib/pleroma/workers/poll_worker.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/workers/poll_worker.ex b/lib/pleroma/workers/poll_worker.ex index caec89cbe..3423cc889 100644 --- a/lib/pleroma/workers/poll_worker.ex +++ b/lib/pleroma/workers/poll_worker.ex @@ -26,8 +26,10 @@ defp find_poll_activity(activity_id) do end def schedule_poll_end(%Activity{data: %{"type" => "Create"}, id: activity_id} = activity) do - with %Object{data: %{"type" => "Question", "closed" => closed}} <- Object.normalize(activity), - {:ok, end_time} <- NaiveDateTime.from_iso8601(closed) do + with %Object{data: %{"type" => "Question", "closed" => closed}} when is_binary(closed) <- + Object.normalize(activity), + {:ok, end_time} <- NaiveDateTime.from_iso8601(closed), + :gt <- NaiveDateTime.compare(end_time, NaiveDateTime.utc_now()) do %{ op: "poll_end", activity_id: activity_id