[Freeswitch-users] LUA script providing dynamic directoryinformation

David Knell dave at 3c.co.uk
Sat Feb 20 13:39:56 PST 2010


Hi Maciej,

Your problem is that Lua won't automatically substitute variables inside a 
string - which is why you're just seeing ..row.email.. passed directly 
through.

If you replace that line in the source with something like
<param name="vm-mailto" value="]] .. row.email .. [["/>

the it's more likely to work.

Cheers --

Dave

----- Original Message ----- 
From: "Maciej Bylica" <mbsip at gazeta.pl>
To: <freeswitch-users at lists.freeswitch.org>
Sent: Saturday, February 20, 2010 10:48 AM
Subject: [Freeswitch-users] LUA script providing dynamic 
directoryinformation


> Hello,
>
> I am trying to use mod_lua to provide dynamic directory information
> (binding in mod_lua.conf.xml)
> Here is my script.
> #!/usr/local/bin/lua
> -- load driver
> require "luasql.odbc"
> -- create environment object
> env = luasql.odbc();
> -- connect to data source
> conn = env:connect("freeswitch","root");
> -- reset our table
> if ( conn ~= nil ) then
> cur = conn:execute(string.format("SELECT email from VM where
> called_num='48112223344'"));
>
> if ( cur ~= nil ) then
> row = cur:fetch({}, "a");
> if ( row ~= nil ) then
>
> freeswitch.consoleLog("info", " Email fetched from DB is = "..
> row.email .."\n");
>
> cur:close(); conn:close(); env:close();
>
> mydialplan = [[
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <document type="freeswitch/xml">
>  <section name="directory">
>    <domain name="10.10.10.1">
>      <user id="48112223344">
>        <params>
>          <param name="vm-email-all-messages" value="true"/>
>          <param name="vm-attach-file" value="true"/>
>          <param name="vm-disk-quota" value="0"/>
>          <param name="vm-email-all-messages" value="true"/>
>          <param name="vm-mailto" value=".. row.email .."/>
>          <param name="vm-keep-local-after-email" value="false"/>
>        </params>
>      </user>
>    </domain>
>  </section>
> </document>
> ]]
>
> XML_STRING = mydialplan
> end
> end
> end
>
>
> I've encountered a problem how to pass row.email gathered from DB
> directly to XML (vm-mailto).
> As you can see below configuration I have does not work properly.
>
> 2010-02-20 20:37:03.267071 [DEBUG] mod_voicemail.c:2358 Deliver VM to
> 48112223344 at 10.10.10.1
> 2010-02-20 20:37:03.276533 [INFO] switch_cpp.cpp:1129  Email fetched
> from DB is = hereis at MyEmaill.com
> 2010-02-20 20:37:03.435902 [DEBUG] switch_utils.c:631 Emailed file
> [/tmp/mail.1266694623f261] to [.. row.email ..]
> 2010-02-20 20:37:03.435902 [DEBUG] mod_voicemail.c:2526 Sending
> message to .. row.email ..
>
> I tried with:
> <param name="vm-mailto" value=.. row.email ../>
> <param name="vm-mailto" value="".. row.email ..""/>
> Both of them do not produce any "Sending message" output at all.
>
>
> Any thoughts?
> Thanks in advance.
> Maciej
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
> 





More information about the FreeSWITCH-users mailing list