From 770a518ad113e561bdaeac89343af3002cc8ef39 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 3 Nov 2022 18:00:42 +0100 Subject: [PATCH] Properly handle un-needed background jobs Cancel them if they're not needed Signed-off-by: Thomas Citharel --- lib/service/workers/notification.ex | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/service/workers/notification.ex b/lib/service/workers/notification.ex index c76e41550..196f8407c 100644 --- a/lib/service/workers/notification.ex +++ b/lib/service/workers/notification.ex @@ -69,7 +69,11 @@ defmodule Mobilizon.Service.Workers.Notification do :ok else - _ -> :ok + %Page{elements: [], total: 0} -> + {:cancel, :no_user_participations} + + _ -> + :ok end end @@ -103,6 +107,9 @@ defmodule Mobilizon.Service.Workers.Notification do :ok else + %Page{elements: [], total: 0} -> + {:cancel, :no_user_participations} + _err -> :ok end @@ -128,6 +135,9 @@ defmodule Mobilizon.Service.Workers.Notification do {:error, :event_not_found} -> {:cancel, :event_participation_not_found} + %Page{elements: [], total: 0} -> + {:cancel, :no_participants_to_approve} + err -> Logger.debug(inspect(err)) err