mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Notification rework - SMTP v0.3 - working ✅
This commit is contained in:
@@ -142,7 +142,7 @@ def create_new_devices (db):
|
||||
FROM CurrentScan"""
|
||||
|
||||
|
||||
mylog('debug',f'[New Devices] 2 Create devices SQL: {sqlQuery}')
|
||||
# mylog('debug',f'[New Devices] Create devices SQL: {sqlQuery}')
|
||||
|
||||
sql.execute (sqlQuery, (startTime, startTime) )
|
||||
|
||||
|
||||
@@ -273,26 +273,43 @@ def get_setting_value(key):
|
||||
|
||||
setting = get_setting(key)
|
||||
|
||||
value = ''
|
||||
|
||||
if setting is not None:
|
||||
|
||||
mylog('none', [f'[SETTINGS] setting json:{json.dumps(setting)}'])
|
||||
|
||||
|
||||
set_type = 'Error: Not handled'
|
||||
set_value = 'Error: Not handled'
|
||||
|
||||
set_value = setting["Value"] # Setting value
|
||||
set_type = setting["Type"] # Setting type
|
||||
set_type = setting["Type"] # Setting type
|
||||
|
||||
# Handle different types of settings
|
||||
if set_type in ['text', 'string', 'password', 'readonly', 'text.select']:
|
||||
return str(set_value)
|
||||
value = str(set_value)
|
||||
elif set_type in ['boolean', 'integer.checkbox']:
|
||||
return bool(set_value)
|
||||
|
||||
value = True
|
||||
|
||||
if set_value in ['false', 'False', 'FALSE', 0]:
|
||||
value = False
|
||||
|
||||
elif set_type in ['integer.select', 'integer']:
|
||||
return int(set_value)
|
||||
value = int(set_value)
|
||||
elif set_type in ['text.multiselect', 'list', 'subnets']:
|
||||
# Assuming set_value is a list in this case
|
||||
return set_value
|
||||
value = set_value
|
||||
elif set_type == '.template':
|
||||
# Assuming set_value is a JSON object in this case
|
||||
return json.loads(set_value)
|
||||
value = json.loads(set_value)
|
||||
else:
|
||||
mylog('none', [f'[SETTINGS] ERROR - set_type not handled:{set_type}'])
|
||||
mylog('none', [f'[SETTINGS] ERROR - setting json:{json.dumps(setting)}'])
|
||||
|
||||
return ''
|
||||
|
||||
return value
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -485,6 +485,8 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr):
|
||||
history_to_insert = []
|
||||
objects_to_update = []
|
||||
|
||||
# only generate events that we want to be notified on (we only need to do this once as all plugObj have the same prefix)
|
||||
statuses_to_report_on = get_setting_value(pluginPref + "_REPORT_ON")
|
||||
|
||||
for plugObj in pluginObjects:
|
||||
# keep old createdTime time if the plugObj already was created before
|
||||
@@ -500,10 +502,7 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr):
|
||||
if plugObj.status == 'new':
|
||||
objects_to_insert.append(values)
|
||||
else:
|
||||
objects_to_update.append(values + (plugObj.index,)) # Include index for UPDATE
|
||||
|
||||
# only generate events that we want to be notified on
|
||||
statuses_to_report_on = get_setting_value(plugObj.pluginPref + "_REPORT_ON")
|
||||
objects_to_update.append(values + (plugObj.index,)) # Include index for UPDATE
|
||||
|
||||
if plugObj.status in statuses_to_report_on:
|
||||
events_to_insert.append(values)
|
||||
|
||||
Reference in New Issue
Block a user