Code cleanup

Fixes #4658
This commit is contained in:
Simone Mainardi 2020-11-02 14:33:25 +01:00
parent 83f75132a5
commit ab73ca7da3

View file

@ -266,16 +266,11 @@ end
-- @param recipient_params A table with endpoint recipient params that will be possibly sanitized
-- @return A table with a key status which is either "OK" or "failed", and the recipient id assigned to the newly added recipient. When "failed", the table contains another key "error" with an indication of the issue
function recipients.add_recipient(endpoint_conf_name, endpoint_recipient_name, user_script_categories, minimum_severity, recipient_params)
-- is_builtin default value is false
is_builtin = (is_builtin or false)
local locked = _lock()
local res = { status = "failed" }
if locked then
local ec = notification_configs.get_endpoint_config(endpoint_conf_name)
local is_builtin_endpoint = ec.endpoint_conf.builtin or false
if ec["status"] == "OK" and endpoint_recipient_name then
-- Is the endpoint already existing?
@ -301,7 +296,7 @@ function recipients.add_recipient(endpoint_conf_name, endpoint_recipient_name, u
ntop.recipient_register(recipient_id)
-- Set a flag to indicate that a recipient has been created
if (not is_builtin_endpoint) and isEmptyString(ntop.getPref(recipients.FIRST_RECIPIENT_CREATED_CACHE_KEY)) then
if not ec.endpoint_conf.builtin and isEmptyString(ntop.getPref(recipients.FIRST_RECIPIENT_CREATED_CACHE_KEY)) then
ntop.setPref(recipients.FIRST_RECIPIENT_CREATED_CACHE_KEY, "1")
end