Adding update

This commit is contained in:
dgtlmoon
2022-12-04 12:48:04 +01:00
parent 3f49d9591c
commit e97c2b3224
+39 -1
View File
@@ -621,4 +621,42 @@ class ChangeDetectionStore:
watch['include_filters'] = [existing_filter]
except:
continue
return
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