mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-02 08:12:21 -07:00
Keep all local changes while resolving conflicts
This commit is contained in:
@@ -16,6 +16,7 @@ from helper import (
|
||||
getBuildTimeStampAndVersion,
|
||||
)
|
||||
from messaging.in_app import write_notification
|
||||
from messaging.notification_sections import SECTION_ORDER
|
||||
from utils.datetime_utils import timeNowUTC, timeNowTZ, get_timezone_offset
|
||||
|
||||
|
||||
@@ -60,12 +61,7 @@ class NotificationInstance:
|
||||
write_file(logPath + "/report_output.json", json.dumps(JSON))
|
||||
|
||||
# Check if nothing to report, end
|
||||
if (
|
||||
JSON["new_devices"] == [] and JSON["down_devices"] == [] and JSON["events"] == [] and JSON["plugins"] == [] and JSON["down_reconnected"] == []
|
||||
):
|
||||
self.HasNotifications = False
|
||||
else:
|
||||
self.HasNotifications = True
|
||||
self.HasNotifications = any(JSON.get(s, []) for s in SECTION_ORDER)
|
||||
|
||||
self.GUID = str(uuid.uuid4())
|
||||
self.DateTimeCreated = timeNowUTC()
|
||||
@@ -129,47 +125,13 @@ class NotificationInstance:
|
||||
mail_text = mail_text.replace("REPORT_DASHBOARD_URL", self.serverUrl)
|
||||
mail_html = mail_html.replace("REPORT_DASHBOARD_URL", self.serverUrl)
|
||||
|
||||
# Start generating the TEXT & HTML notification messages
|
||||
# new_devices
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "new_devices")
|
||||
|
||||
mail_text = mail_text.replace("NEW_DEVICES_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("NEW_DEVICES_TABLE", html)
|
||||
mylog("verbose", ["[Notification] New Devices sections done."])
|
||||
|
||||
# down_devices
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "down_devices")
|
||||
|
||||
mail_text = mail_text.replace("DOWN_DEVICES_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("DOWN_DEVICES_TABLE", html)
|
||||
mylog("verbose", ["[Notification] Down Devices sections done."])
|
||||
|
||||
# down_reconnected
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "down_reconnected")
|
||||
|
||||
mail_text = mail_text.replace("DOWN_RECONNECTED_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("DOWN_RECONNECTED_TABLE", html)
|
||||
mylog("verbose", ["[Notification] Reconnected Down Devices sections done."])
|
||||
|
||||
# events
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "events")
|
||||
|
||||
mail_text = mail_text.replace("EVENTS_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("EVENTS_TABLE", html)
|
||||
mylog("verbose", ["[Notification] Events sections done."])
|
||||
|
||||
# plugins
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "plugins")
|
||||
|
||||
mail_text = mail_text.replace("PLUGINS_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("PLUGINS_TABLE", html)
|
||||
|
||||
mylog("verbose", ["[Notification] Plugins sections done."])
|
||||
# Generate TEXT & HTML for each notification section
|
||||
for section in SECTION_ORDER:
|
||||
html, text = construct_notifications(self.JSON, section)
|
||||
placeholder = f"{section.upper()}_TABLE"
|
||||
mail_text = mail_text.replace(placeholder, text + "\n")
|
||||
mail_html = mail_html.replace(placeholder, html)
|
||||
mylog("verbose", [f"[Notification] {section} section done."])
|
||||
|
||||
final_text = removeDuplicateNewLines(mail_text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user