mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
BLF Presence added for Voicemail Boxes (#6389)
* BLF Presence added for Voicemail Boxes * Newline added to the end of the blf_notify.lua script * changed prefix of vmail to voicemail
This commit is contained in:
committed by
GitHub
parent
d097d5b64c
commit
c73f4de8d1
@@ -11,7 +11,7 @@
|
||||
<action application="lua" data="app.lua voicemail"/>
|
||||
<!--<action application="voicemail" data="check default ${domain_name}"/>-->
|
||||
</condition>
|
||||
<condition field="destination_number" expression="^(vmain$|^\*4000$|^\*98)(\d{2,12})$">
|
||||
<condition field="destination_number" expression="^(vmain$|^\*4000$|^\*98|voicemail\+)(\d{2,12})$">
|
||||
<action application="answer"/>
|
||||
<action application="sleep" data="1000"/>
|
||||
<action application="set" data="record_append=false"/>
|
||||
|
||||
@@ -330,6 +330,7 @@
|
||||
require "app.voicemail.resources.functions.record_name";
|
||||
require "app.voicemail.resources.functions.message_count"
|
||||
require "app.voicemail.resources.functions.mwi_notify";
|
||||
require "app.voicemail.resources.functions.blf_notify";
|
||||
require "app.voicemail.resources.functions.tutorial";
|
||||
|
||||
--send a message waiting event
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
function blf_notify(on, user, uuid)
|
||||
|
||||
require "resources.functions.split"
|
||||
local api = require "resources.functions.api"
|
||||
local log = require "resources.functions.log".presence
|
||||
|
||||
log.debugf('turn_lamp: %s - %s(%s)', tostring(user), tostring(on), type(on))
|
||||
|
||||
local userid, domain, proto = split_first(user, "@", true)
|
||||
proto, userid = split_first(userid, "+", true)
|
||||
if userid then
|
||||
user = userid .. "@" .. domain
|
||||
else
|
||||
proto = "sip"
|
||||
end
|
||||
|
||||
uuid = uuid or api:execute('create_uuid')
|
||||
|
||||
local event = freeswitch.Event("PRESENCE_IN");
|
||||
event:addHeader("proto", proto);
|
||||
event:addHeader("event_type", "presence");
|
||||
event:addHeader("alt_event_type", "dialog");
|
||||
event:addHeader("Presence-Call-Direction", "outbound");
|
||||
event:addHeader("from", user);
|
||||
event:addHeader("login", user);
|
||||
event:addHeader("unique-id", uuid);
|
||||
event:addHeader("status", "Active (1 waiting)");
|
||||
if on then
|
||||
event:addHeader("answer-state", "confirmed");
|
||||
event:addHeader("rpid", "unknown");
|
||||
event:addHeader("event_count", "1");
|
||||
else
|
||||
event:addHeader("answer-state", "terminated");
|
||||
end
|
||||
|
||||
-- log.debug(event:serialize())
|
||||
|
||||
event:fire();
|
||||
end
|
||||
|
||||
return {
|
||||
turn_lamp = turn_lamp;
|
||||
}
|
||||
@@ -155,6 +155,7 @@
|
||||
|
||||
--send the message waiting event
|
||||
mwi_notify(forward_voicemail_id.."@"..domain_name, new_messages, saved_messages)
|
||||
blf_notify(tonumber(new_messages) > 0, "voicemail+" .. forward_voicemail_id .. "@" .. domain_name)
|
||||
|
||||
--if local after email is true then copy the recording file
|
||||
if (storage_type ~= "base64") then
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
)
|
||||
--send the message waiting event
|
||||
mwi_notify(voicemail_id.."@"..domain_name, new_messages, saved_messages)
|
||||
blf_notify(tonumber(new_messages) > 0, "voicemail+" .. voicemail_id .. "@" .. domain_name)
|
||||
--fix for extensions that start with 0 (Ex: 0712)
|
||||
if (voicemail_id_copy ~= voicemail_id and voicemail_id_copy ~= nil) then
|
||||
message_waiting(voicemail_id_copy, domain_uuid);
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
local account = value.."@"..domain_name;
|
||||
--send the message waiting notifications
|
||||
mwi_notify(account, new_messages, saved_messages);
|
||||
blf_notify(tonumber(new_messages) > 0, "voicemail+" .. voicemail_id .. "@" .. domain_name)
|
||||
--send information to the console
|
||||
if (debug["info"]) then
|
||||
if new_messages == "0" then
|
||||
|
||||
@@ -16,6 +16,28 @@ local presence_in = require "resources.functions.presence_in"
|
||||
local Database = require "resources.functions.database"
|
||||
local BasicEventService = require "resources.functions.basic_event_service"
|
||||
|
||||
local find_voicemail do
|
||||
|
||||
local find_voicemail_sql = [[select t1.voicemail_message_uuid
|
||||
from v_voicemail_messages t1
|
||||
inner join v_domains t2 on t1.domain_uuid = t2.domain_uuid
|
||||
inner join v_voicemails t3 on t1.voicemail_uuid = t3.voicemail_uuid
|
||||
where t2.domain_name = :domain_name and t3.voicemail_id = :extension and t1.message_status != 'saved']]
|
||||
|
||||
function find_voicemail(user)
|
||||
local ext, domain_name = split_first(user, '@', true)
|
||||
log.notice("ext: " .. ext);
|
||||
log.notice("domain_name: " .. domain_name);
|
||||
if not domain_name then return end
|
||||
local dbh = Database.new('system')
|
||||
if not dbh then return end
|
||||
local voicemail = dbh:first_row(find_voicemail_sql, {domain_name = domain_name, extension = ext})
|
||||
dbh:release()
|
||||
return voicemail
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local find_call_flow do
|
||||
|
||||
local find_call_flow_sql = [[select t1.call_flow_uuid, t1.call_flow_status
|
||||
@@ -113,6 +135,24 @@ end
|
||||
|
||||
local protocols = {}
|
||||
|
||||
protocols.voicemail = function(event)
|
||||
local from, to = event:getHeader('from'), event:getHeader('to')
|
||||
local expires = tonumber(event:getHeader('expires'))
|
||||
if expires and expires > 0 then
|
||||
local proto, user = split_first(to, '+', true)
|
||||
local voicemail_status = find_voicemail(user)
|
||||
if voicemail_status then
|
||||
log.noticef("Find VOICEMAIL: %s status: %s", to, tostring(voicemail_status))
|
||||
presence_in.turn_lamp(true, to)
|
||||
else
|
||||
log.warningf("Can not find VOICEMAIL: %s", to)
|
||||
presence_in.turn_lamp(false, to)
|
||||
end
|
||||
else
|
||||
log.noticef("%s UNSUBSCRIBE from %s", from, to)
|
||||
end
|
||||
end
|
||||
|
||||
protocols.flow = function(event)
|
||||
local from, to = event:getHeader('from'), event:getHeader('to')
|
||||
local expires = tonumber(event:getHeader('expires'))
|
||||
|
||||
Reference in New Issue
Block a user