From e97c2b3224fc41600410e87d14e0bc3b2dfc0e84 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sun, 4 Dec 2022 12:48:04 +0100 Subject: [PATCH] Adding update --- changedetectionio/store.py | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/changedetectionio/store.py b/changedetectionio/store.py index d64f5f4e0..9d555f8b8 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -621,4 +621,42 @@ class ChangeDetectionStore: watch['include_filters'] = [existing_filter] except: continue - return \ No newline at end of file + return + + # Convert old static notification tokens to jinja2 tokens + def update_11(self): + # Each watch + import re + for uuid, watch in self.data['watching'].items(): + try: + n_body = watch.get('notification_body', '') + if n_body: + watch['notification_body'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_body) + + n_title = watch.get('notification_title') + if n_title: + self.data['settings']['application']['notification_title'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_title) + + n_urls = watch.get('notification_urls') + if n_urls: + for i, url in enumerate(n_urls): + watch['notification_urls'][i] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', url) + + except: + continue + + # System wide + n_body = self.data['settings']['application'].get('notification_body') + if n_body: + self.data['settings']['application']['notification_body'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_body) + + n_title = self.data['settings']['application'].get('notification_title') + if n_body: + self.data['settings']['application']['notification_title'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_title) + + n_urls = self.data['settings']['application'].get('notification_urls') + if n_urls: + for i, url in enumerate(n_urls): + self.data['settings']['application']['notification_urls'][i] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', url) + + return