Explanation on creating the dialplan.{domain_name} cache file

Status
Not open for further replies.

cargreg

New Member
Apr 26, 2018
27
2
3
36
Hi guys,
I'm working on my fusionpbx API,
i need an explanation what happens when we create for example a time condition, i put all the information inside the database, i can view the time condition i create but when i try to put it in an incoming route the call stops.
I noticed that the time condition is not present in the cache file, if I enter it manually it starts to work, at least as long as the cache file is present.
Or another way to make the condition work is to access it via the dialplan manager and click the save button
 

mcs3ss2

Active Member
Sep 8, 2020
254
27
28
AU
I had this happened
I did not dig into this too much
i deleted the time condition
i rebooted the server
i created new TC
worked like a charm
 

cargreg

New Member
Apr 26, 2018
27
2
3
36
thanks for reply, but i tried to create the time condition through api writed myself
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,414
376
83
Look at /var/www/fusionpbx/resources/switch.php and find the function called save_dialplan_xml(), this updates the cache file(s) when a dialplan is edited, in your case when a time condition is edited.
 

cargreg

New Member
Apr 26, 2018
27
2
3
36
thanks a lot for your reply,
I think what I'm looking for is app/scripts/app/xml_handler/index.lua, this function should be call at avery call and if I understood correctly it generate the dialplan.domain name xml cache file
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,414
376
83
The xml_handler .lua scripts are generally called by FreeSWITCH when it needs some configuration information. You can see this being set up in /etc/freeswitch/autoload_configs/lua.conf.xml.
Here is the relevant section in that file:
Code:
 <!--
    Deliver XML from lua with the XML Handler
    -->
    <param name="xml-handler-script" value="app.lua xml_handler"/>
    <param name="xml-handler-bindings" value="configuration,dialplan,directory,languages"/>
 

cargreg

New Member
Apr 26, 2018
27
2
3
36
the strange thing is that thanks to my api I can create a time condition
fusionpbx=# select * from v_dialplans where dialplan_uuid = '49b840e9-7e8a-4345-8566-df7ddabc3ea3';
-[ RECORD 1 ]--------+----------------------------------------------------------------------------------------------
domain_uuid | 62a0c886-8c01-4b5b-9a67-1eb6538753ef
dialplan_uuid | 49b840e9-7e8a-4345-8566-df7ddabc3ea3
app_uuid | 4b821450-926b-175a-af93-a03c441818b1
hostname |
dialplan_context | test-domain.fusionpbx.xxxx.xx
dialplan_name | test
dialplan_number | 300
dialplan_continue | false
dialplan_xml | <extension name="test" continue="true" uuid="49b840e9-7e8a-4345-8566-df7ddabc3ea3"> +
| <condition field="destination_number" expression="^300$"/> +
| <condition year="2022-2023" mon="5-8" mday="8-25" break="never"> +
| <action application="transfer" data="100 XML test.fusionpbx.xxxx.xx"/>+
| </condition> +
| <condition field="destination_number" expression="^300$"> +
| <action application="lua" data="streamfile.lua acdc_mono.wav"/> +
| </condition> +
| </extension>
dialplan_order | 300
dialplan_enabled | true
dialplan_description | blablabla
dialplan_destination | false

but i can't find the extension inside the cache file so the call finish with "480 Temporarily Unavailable"
but if i put manually the xml in the cache file the timecondition start to work
 

cargreg

New Member
Apr 26, 2018
27
2
3
36
hi guys,
finally i found the problem, as you can see above the hostname field is empty but not null,
every time i create a timecondition or else i call a function to clean the cache so this query
sql = "select dialplan_xml from v_dialplans as p ";
if (context_name == "public" or string.match(context_name, "@")) then
sql = sql .. "where p.dialplan_context = :call_context ";
else
sql = sql .. "where p.dialplan_context in :)call_context, '${domain_name}', 'global') ";
end
sql = sql .. "and (p.hostname = :hostname or p.hostname is null) ";
sql = sql .. "and p.dialplan_enabled = 'true' ";
sql = sql .. "order by p.dialplan_order asc ";
inside the
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua
fails and the extension was not being written to the cache file
 
Status
Not open for further replies.