mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Notification rework v0.4
This commit is contained in:
@@ -154,7 +154,7 @@ def main ():
|
||||
notiStructure = get_notifications(db)
|
||||
|
||||
# Write the notifications into the DB
|
||||
notification = Notification_obj(db)
|
||||
notification = Notification_obj(db)
|
||||
hasNotification = notification.create(notiStructure.json, notiStructure.text, notiStructure.html, "")
|
||||
|
||||
# run all enabled publisher gateways
|
||||
@@ -162,6 +162,21 @@ def main ():
|
||||
pluginsState = run_plugin_scripts(db, 'on_notification', pluginsState)
|
||||
notification.setAllProcessed()
|
||||
|
||||
# Clean Pending Alert Events
|
||||
sql.execute ("""UPDATE Devices SET dev_LastNotification = ?
|
||||
WHERE dev_MAC IN (
|
||||
SELECT eve_MAC FROM Events
|
||||
WHERE eve_PendingAlertEmail = 1
|
||||
)
|
||||
""", (timeNowTZ(),) )
|
||||
sql.execute ("""UPDATE Events SET eve_PendingAlertEmail = 0
|
||||
WHERE eve_PendingAlertEmail = 1""")
|
||||
|
||||
# clear plugin events
|
||||
sql.execute ("DELETE FROM Plugins_Events")
|
||||
|
||||
# DEBUG - print number of rows updated
|
||||
mylog('minimal', ['[Notification] Notifications changes: ', sql.rowcount])
|
||||
|
||||
# Commit SQL
|
||||
db.commitDB()
|
||||
|
||||
@@ -315,22 +315,6 @@ def get_notifications (db):
|
||||
# else :
|
||||
# mylog('verbose', ['[Notification] No changes to report'])
|
||||
|
||||
# # Clean Pending Alert Events
|
||||
# sql.execute ("""UPDATE Devices SET dev_LastNotification = ?
|
||||
# WHERE dev_MAC IN (SELECT eve_MAC FROM Events
|
||||
# WHERE eve_PendingAlertEmail = 1)
|
||||
# """, (datetime.datetime.now(conf.tz),) )
|
||||
# sql.execute ("""UPDATE Events SET eve_PendingAlertEmail = 0
|
||||
# WHERE eve_PendingAlertEmail = 1""")
|
||||
|
||||
# # clear plugin events
|
||||
# sql.execute ("DELETE FROM Plugins_Events")
|
||||
|
||||
# # DEBUG - print number of rows updated
|
||||
# mylog('minimal', ['[Notification] Notifications changes: ', sql.rowcount])
|
||||
|
||||
# # Commit changes
|
||||
# db.commitDB()
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user