diff --git a/resources/install/scripts/resources/functions/format_ringback.lua b/resources/install/scripts/resources/functions/format_ringback.lua index 032b666cb6..83dcc95547 100644 --- a/resources/install/scripts/resources/functions/format_ringback.lua +++ b/resources/install/scripts/resources/functions/format_ringback.lua @@ -1,21 +1,26 @@ --add the format_ringback function - function format_ringback (ringback) - if (ringback == nil or ringback == "") then - --get the default ring back - ringback = session:getVariable("hold_music"); - elseif (ringback:match("%${.*}")) then - --strip the ${ and } - ringback = ringback:gsub("%${", ""); - ringback = ringback:gsub("}", ""); - --get the ringback variable - ringback = session:getVariable(ringback); - --fallback to us-ring - if (ringback == "") then - ringback = session:getVariable("us-ring"); - end - --convert to tone_stream - ringback = "tone_stream://" .. ringback .. ";loops=-1"; - end + function format_ringback (ringback) + --include trim + require "resources.functions.trim"; + --prepare the api object + api = freeswitch.API(); + --handle ringback + if (ringback == nil or ringback == "") then + --get the default ring back + ringback = trim(api:execute("global_getvar", "hold_music")); + elseif (ringback:match("%${.*}")) then + --strip the ${ and } + ringback = ringback:gsub("%${", ""); + ringback = ringback:gsub("}", ""); + --get the ringback variable + ringback = trim(api:execute("global_getvar", ringback)); + --fallback to us-ring + if (ringback == "") then + ringback = trim(api:execute("global_getvar", "us-ring")); + end + --convert to tone_stream + ringback = "tone_stream://" .. ringback .. ";loops=-1"; + end return ringback; end \ No newline at end of file