require "resources.functions.config";
require "resources.functions.settings";
--make sure the session is ready
if ( session:ready() ) then
--set the sounds path for the language, dialect and voice
default_language = session:getVariable("default_language");
default_dialect = session:getVariable("default_dialect");
default_voice = session:getVariable("default_voice");
if (not default_language) then default_language = 'en'; end
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
--get the variables
if (session:getVariable("masked") == null) then
masked = "false";
else
masked = session:getVariable("masked");
end
uuid = session:getVariable("bridge_uuid");
path = session:getVariable("api_on_answer");
path = string.gsub(path, ".* start ", "")
--mask or unmask the recording
api = freeswitch.API();
if (masked == "false") then
freeswitch.consoleLog("notice", "[recording] Masking call "..uuid.."\n");
cmd = "uuid_record "..uuid.." mask "..path;
freeswitch.consoleLog("notice", cmd);
reply = api:executeString(cmd);
if (string.sub(reply, 0, 1) == "-") then
sound = "uuid_broadcast "..uuid.." "..sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/misc/error.wav both";
else
sound = "uuid_broadcast "..uuid.." "..sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-recording_paused.wav both";
session:setVariable("masked", "true");
end
api:executeString(sound);
else
freeswitch.consoleLog("notice", "[recording] Unmasking call "..uuid.."\n");
cmd = "uuid_record "..uuid.." unmask "..path;
reply = api:executeString(cmd);
if (string.sub(reply, 0, 1) == "-") then
sound = "uuid_broadcast "..uuid.." "..sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/misc/error.wav both";
else
sound = "uuid_broadcast "..uuid.." "..sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-recording_started.wav both";
session:setVariable("masked", "false");
end
api:executeString(sound);
end
end