Ignored IPs not applied #836

This commit is contained in:
jokob-sk
2024-10-11 20:05:23 +11:00
parent f9e6871ab2
commit c4e0abf913
3 changed files with 6 additions and 7 deletions

View File

@@ -0,0 +1 @@
1

View File

@@ -463,7 +463,7 @@ def list_to_where(logical_operator, column_name, condition_operator, values_list
"""
if not values_list:
return "" # Return an empty string if the list is empty to avoid breaking the SQL condition.
return " AND 1=1 " # Return a conditioneitehr way if the list is empty to avoid breaking the SQL condition.
# Replace {s-quote} with single quote in values_list
values_list = [value.replace("{s-quote}", "'") for value in values_list]

View File

@@ -61,11 +61,10 @@ def get_notifications (db):
mylog('verbose', ['[Notification] Included sections: ', sections ])
if 'new_devices' in sections:
# Compose New Devices Section
# Compose New Devices Section (no empty lines in SQL queries!)
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
WHERE eve_PendingAlertEmail = 1
AND eve_EventType = 'New Device'
{get_setting_value('NTFPRCS_new_dev_condition').replace('{s-quote}',"'")}
AND eve_EventType = 'New Device' {get_setting_value('NTFPRCS_new_dev_condition').replace('{s-quote}',"'")}
ORDER BY eve_DateTime"""
mylog('debug', ['[Notification] new_devices SQL query: ', sqlQuery ])
@@ -133,11 +132,10 @@ def get_notifications (db):
mylog('debug', ['[Notification] json_down_reconnected: ', json.dumps(json_down_reconnected) ])
if 'events' in sections:
# Compose Events Section
# Compose Events Section (no empty lines in SQL queries!)
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
WHERE eve_PendingAlertEmail = 1
AND eve_EventType IN ('Connected', 'Down Reconnected', 'Disconnected','IP Changed')
{get_setting_value('NTFPRCS_event_condition').replace('{s-quote}',"'")}
AND eve_EventType IN ('Connected', 'Down Reconnected', 'Disconnected','IP Changed') {get_setting_value('NTFPRCS_event_condition').replace('{s-quote}',"'")}
ORDER BY eve_DateTime"""
mylog('debug', ['[Notification] events SQL query: ', sqlQuery ])