Change. Use BasicEventService to implement MWI service. (#2855)
This commit is contained in:
committed by
FusionPBX
parent
41083c7a8c
commit
f91c6eb163
@@ -1,14 +1,13 @@
|
|||||||
require "resources.functions.config"
|
require "resources.functions.config"
|
||||||
require "resources.functions.split"
|
require "resources.functions.split"
|
||||||
|
|
||||||
local log = require "resources.functions.log".mwi_subscribe
|
|
||||||
local EventConsumer = require "resources.functions.event_consumer"
|
|
||||||
local Database = require "resources.functions.database"
|
|
||||||
local cache = require "resources.functions.cache"
|
|
||||||
local mwi_notify = require "app.voicemail.resources.functions.mwi_notify"
|
|
||||||
|
|
||||||
local service_name = "mwi"
|
local service_name = "mwi"
|
||||||
local pid_file = scripts_dir .. "/run/" .. service_name .. ".tmp"
|
|
||||||
|
local log = require "resources.functions.log"[service_name]
|
||||||
|
local BasicEventService = require "resources.functions.basic_event_service"
|
||||||
|
local Database = require "resources.functions.database"
|
||||||
|
local cache = require "resources.functions.cache"
|
||||||
|
local mwi_notify = require "app.voicemail.resources.functions.mwi_notify"
|
||||||
|
|
||||||
local vm_message_count do
|
local vm_message_count do
|
||||||
|
|
||||||
@@ -82,29 +81,10 @@ end
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local events = EventConsumer.new(pid_file)
|
local service = BasicEventService.new(log, service_name)
|
||||||
|
|
||||||
-- FS shutdown
|
|
||||||
events:bind("SHUTDOWN", function(self, name, event)
|
|
||||||
log.notice("shutdown")
|
|
||||||
return self:stop()
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Control commands from FusionPBX
|
|
||||||
events:bind("CUSTOM::fusion::service::control", function(self, name, event)
|
|
||||||
if service_name ~= event:getHeader('service-name') then return end
|
|
||||||
|
|
||||||
local command = event:getHeader('service-command')
|
|
||||||
if command == "stop" then
|
|
||||||
log.notice("get stop command")
|
|
||||||
return self:stop()
|
|
||||||
end
|
|
||||||
|
|
||||||
log.warningf('Unknown service command: %s', command or '<NONE>')
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- MWI SUBSCRIBE
|
-- MWI SUBSCRIBE
|
||||||
events:bind("MESSAGE_QUERY", function(self, name, event)
|
service:bind("MESSAGE_QUERY", function(self, name, event)
|
||||||
local account_header = event:getHeader('Message-Account')
|
local account_header = event:getHeader('Message-Account')
|
||||||
if not account_header then
|
if not account_header then
|
||||||
return log.warningf("MWI message without `Message-Account` header")
|
return log.warningf("MWI message without `Message-Account` header")
|
||||||
@@ -127,6 +107,6 @@ end)
|
|||||||
|
|
||||||
log.notice("start")
|
log.notice("start")
|
||||||
|
|
||||||
events:run()
|
service:run()
|
||||||
|
|
||||||
log.notice("stop")
|
log.notice("stop")
|
||||||
|
|||||||
Reference in New Issue
Block a user