mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 10:41:34 +00:00
Initial implementation of OO recipients and integer ids
This commit is contained in:
parent
5db42ecec4
commit
3cefe89d4b
7 changed files with 489 additions and 26 deletions
78
attic/scripts/lua/modules/recipients/recipients.lua
Normal file
78
attic/scripts/lua/modules/recipients/recipients.lua
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
--
|
||||
-- (C) 2017-20 - ntop.org
|
||||
--
|
||||
|
||||
local json = require "dkjson"
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local recipients = {}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function recipients:create(args)
|
||||
if args then
|
||||
-- We're being sub-classed
|
||||
if not args.key then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
local this = args or {key = "base", enabled = true}
|
||||
|
||||
setmetatable(this, self)
|
||||
self.__index = self
|
||||
|
||||
if args then
|
||||
-- Initialization is only run if a subclass is being instanced, that is,
|
||||
-- when args is not nil
|
||||
this:_initialize()
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Performs initialization operations at the time when the instance is created
|
||||
function recipients:_initialize()
|
||||
-- Possibly create a default recipient (if not existing)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Dispatches a store `notification` to the recipient
|
||||
-- @param notification A JSON string with all the alert information
|
||||
-- @return true If the dispatching has been successfull, false otherwise
|
||||
function recipients:dispatch_store_notification(notification)
|
||||
return self.enabled
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Dispatches a trigger `notification` to the recipient
|
||||
-- @param notification A JSON string with all the alert information
|
||||
-- @return true If the dispatching has been successfull, false otherwise
|
||||
function recipients:dispatch_trigger_notification(notification)
|
||||
return self.enabled
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Dispatches a release `notification` to the recipient
|
||||
-- @param notification A JSON string with all the alert information
|
||||
-- @return true If the dispatching has been successfull, false otherwise
|
||||
function recipients:dispatch_release_notification(notification)
|
||||
return self.enabled
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Process notifications previously dispatched with one of the dispatch_{store,trigger,release}_notification
|
||||
function recipients:process_notifications()
|
||||
return self.enabled
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return recipients
|
||||
Loading…
Add table
Add a link
Reference in a new issue