From a13f099e14e0438cd6e8e8d7a6d59346151f1c7f Mon Sep 17 00:00:00 2001 From: Ashish D'Souza Date: Sat, 20 May 2023 18:21:11 -0500 Subject: [PATCH] Update 'notify/src/ntfy.py' --- notify/src/ntfy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notify/src/ntfy.py b/notify/src/ntfy.py index 9c7a903..216df0f 100644 --- a/notify/src/ntfy.py +++ b/notify/src/ntfy.py @@ -3,15 +3,15 @@ import requests from datetime import datetime, timedelta -last_notification_time = None +last_notification_time = {} def send_rate_limited_notification(event_id, camera, object_label, score, quiet_period=1): global last_notification_time now = datetime.now() - if last_notification_time is None or now - last_notification_time >= timedelta(minutes=quiet_period): - last_notification_time = now + if camera not in last_notification_time or now - last_notification_time[camera] >= timedelta(minutes=quiet_period): + last_notification_time[camera] = now send_notification(event_id, camera, object_label, score, priority=3)