mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-31 07:12:23 -07:00
DOCS+FE+BE: cleanup, SSE wait for app initialization #1440
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -1401,7 +1401,7 @@ def api_create_event(mac, payload=None):
|
||||
def api_events_by_mac(mac, payload=None):
|
||||
"""Delete events for a specific device MAC; string converter keeps this distinct from /events/<int:days>."""
|
||||
device_handler = DeviceInstance()
|
||||
|
||||
|
||||
result = device_handler.deleteDeviceEvents(mac)
|
||||
return jsonify(result)
|
||||
|
||||
@@ -1740,7 +1740,8 @@ def api_write_notification(payload=None):
|
||||
auth_callable=is_authorized
|
||||
)
|
||||
def api_get_unread_notifications(payload=None):
|
||||
return get_unread_notifications()
|
||||
notifications = get_unread_notifications()
|
||||
return jsonify(notifications)
|
||||
|
||||
|
||||
@app.route("/messaging/in-app/read/all", methods=["POST"])
|
||||
|
||||
@@ -231,7 +231,7 @@ def get_unread_notifications():
|
||||
notifications = json.load(f)
|
||||
|
||||
unread = [n for n in notifications if n.get("read", 0) == 0]
|
||||
return jsonify(unread)
|
||||
return unread
|
||||
|
||||
|
||||
def mark_notification_as_read(guid=None, max_attempts=3):
|
||||
@@ -283,6 +283,13 @@ def mark_notification_as_read(guid=None, max_attempts=3):
|
||||
return {"success": False, "error": error_msg}
|
||||
|
||||
|
||||
def update_unread_notifications_count():
|
||||
"""
|
||||
Re-broadcast unread notifications for the frontend .
|
||||
"""
|
||||
broadcast_unread_notifications_count(len(get_unread_notifications()))
|
||||
|
||||
|
||||
def delete_notification(guid):
|
||||
"""
|
||||
Delete a notification from the notifications file based on its GUID.
|
||||
|
||||
@@ -17,6 +17,7 @@ from db.db_helper import print_table_schema
|
||||
from utils.datetime_utils import timeNowDB
|
||||
from logger import mylog, Logger
|
||||
from messaging.reporting import skip_repeated_notifications
|
||||
from messaging.in_app import update_unread_notifications_count
|
||||
|
||||
|
||||
# Make sure log level is initialized correctly
|
||||
@@ -104,6 +105,9 @@ def process_scan(db):
|
||||
# 🐛 CurrentScan DEBUG: comment out below when debugging to keep the CurrentScan table after restarts/scan finishes
|
||||
db.sql.execute("DELETE FROM CurrentScan")
|
||||
|
||||
# re-broadcast unread notifiation count to update FE
|
||||
update_unread_notifications_count()
|
||||
|
||||
# Commit changes
|
||||
db.commitDB()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user