From e154a3cb7a9171e6ec87df95d8f5d588e5c15e9f Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 10 Sep 2022 15:01:11 +0200 Subject: [PATCH] Notification system update - set watch to use defaults if it is the same as the default --- changedetectionio/store.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/changedetectionio/store.py b/changedetectionio/store.py index d6f74146..53c50b79 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -536,3 +536,24 @@ class ChangeDetectionStore: except: continue return + + def update_5(self): + # If the watch notification body, title look the same as the global one, unset it, so the watch defaults back to using the main settings + # In other words - the watch notification_title and notification_body are not needed if they are the same as the default one + current_system_body = self.data['settings']['application']['notification_body'].translate(str.maketrans('', '', "\r\n ")) + current_system_title = self.data['settings']['application']['notification_body'].translate(str.maketrans('', '', "\r\n ")) + for uuid, watch in self.data['watching'].items(): + try: + watch_body = watch.get('notification_body', '') + if watch_body and watch_body.translate(str.maketrans('', '', "\r\n ")) == current_system_body: + # Looks the same as the default one, so unset it + watch['notification_body'] = None + + watch_title = watch.get('notification_title', '') + if watch_title and watch_title.translate(str.maketrans('', '', "\r\n ")) == current_system_title: + # Looks the same as the default one, so unset it + watch['notification_title'] = None + except Exception as e: + continue + return +