<h1>Project "FreeSWITCH user-contributed scripts, etc" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: 164b017dbbd88db3f85dbfb3a21e320b8c54e46a (commit)
       via: 9ff716208ae05c3e9cb55d639243371e8553bb17 (commit)
       via: a4349bbeba56858b0c17f8b69ed69ecebba0bc58 (commit)
       via: d93d8a0e353b8a112167961178bffda485356ee7 (commit)
       via: f192c27939941db18bdf2c543a9e14b21ae16fd0 (commit)
      from: 319c6bf92e7368d4ce0c7bfdd2efb569368579f2 (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Mitch Capper
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch-contrib
</pre></div>
<div class="highlight"><pre>committer: Chad Phillips
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch-contrib
</pre></div>
<div class="highlight"><pre>committer: Chad Phillips
comments: 
Merge branch &#39;master&#39; of ssh://scratch/usr/local/src/freeswitch-contrib
</pre></div>
<div class="highlight"><pre>committer: Chad Phillips
comments: 
adding service module, for accessing external services -- intial code has an http_request action, which allows GET requests using the HTTP protocol.

<span style="color: #000080; font-weight: bold">diff --git a/hunmonk/jester/conf.lua b/hunmonk/jester/conf.lua</span>
<span style="color: #000080; font-weight: bold">index 721c602..3cc79f1 100644</span>
<span style="color: #A00000">--- a/hunmonk/jester/conf.lua</span>
<span style="color: #00A000">+++ b/hunmonk/jester/conf.lua</span>
<span style="color: #800080; font-weight: bold">@@ -61,6 +61,7 @@ modules = {</span>
   &quot;navigation&quot;,
   &quot;play&quot;,
   &quot;record&quot;,
<span style="color: #00A000">+  &quot;service&quot;,</span>
   &quot;system&quot;,
   &quot;tracker&quot;,
 }
<span style="color: #000080; font-weight: bold">diff --git a/hunmonk/jester/modules/service/conf.lua b/hunmonk/jester/modules/service/conf.lua</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..20d75b8</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/hunmonk/jester/modules/service/conf.lua</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,5 @@</span>
<span style="color: #00A000">+jester.action_map.http_request = {</span>
<span style="color: #00A000">+  mod = &quot;service&quot;,</span>
<span style="color: #00A000">+  func = &quot;http_request&quot;,</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #000080; font-weight: bold">diff --git a/hunmonk/jester/modules/service/help.lua b/hunmonk/jester/modules/service/help.lua</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..41ce8a8</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/hunmonk/jester/modules/service/help.lua</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,39 @@</span>
<span style="color: #00A000">+jester.help_map.service = {}</span>
<span style="color: #00A000">+jester.help_map.service.description_short = [[Access external services.]]</span>
<span style="color: #00A000">+jester.help_map.service.description_long = [[This module provides actions for accessing external services, such as webservices.]]</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+jester.help_map.service.actions = {}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+jester.help_map.service.actions.http_request = {}</span>
<span style="color: #00A000">+jester.help_map.service.actions.http_request.description_short = [[Make an HTTP request to a external server.]]</span>
<span style="color: #00A000">+jester.help_map.service.actions.http_request.description_long = [[Make an HTTP request to an external server.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+Only the http:// protocol is supported.  The resulting status of the request is stored in the &#39;last_http_request&#39; storage area, with the following keys:</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+  code:</span>
<span style="color: #00A000">+    An HTTP/1.1 return code, or &#39;error&#39; if the request fails.</span>
<span style="color: #00A000">+  description:</span>
<span style="color: #00A000">+    A human-readable description of the code.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+If the request returns a &#39;200&#39; code, then the body of the response will be stored according to the parameter settings.]]</span>
<span style="color: #00A000">+jester.help_map.service.actions.http_request.params = {</span>
<span style="color: #00A000">+  server = [[(Optional) The server to send the request to, eg. &#39;www.example.com&#39;. Default is &#39;localhost&#39;.]],</span>
<span style="color: #00A000">+  port = [[(Optional) The port to send the request to.  Default is 80.]],</span>
<span style="color: #00A000">+  path = [[(Optional) The server path to send the request to, no leading or trailing slash, eg. &#39;path/to/resource&#39;.]],</span>
<span style="color: #00A000">+  query = [[(Optional) A table of query parameters to append to the URL.  Keys must be only numbers, letters, and underscores, values can be any string and will be properly URL escaped before sending, eg. &#39;{foo = &quot;bar&quot;, baz = &quot;two words&quot;}&#39;.]],</span>
<span style="color: #00A000">+  fragment = [[(Optional) A fragment to append to the URL.  It will be properly escaped before sending.]],</span>
<span style="color: #00A000">+  user = [[(Optional) A user name to use for basic authentication.]],</span>
<span style="color: #00A000">+  password = [[(Optional) A password to use for basic authentication.  &#39;user&#39; parameter must also be provided.]],</span>
<span style="color: #00A000">+  response = [[(Optional) The format to expect the response in:</span>
<span style="color: #00A000">+  lua:</span>
<span style="color: #00A000">+    A string that represents a Lua table, of the following format:</span>
<span style="color: #00A000">+      return {</span>
<span style="color: #00A000">+        foo = &#39;bar&#39;,</span>
<span style="color: #00A000">+      }</span>
<span style="color: #00A000">+      The table data will be loaded into the specified storage area. Table values cannot contain a table.</span>
<span style="color: #00A000">+  raw:</span>
<span style="color: #00A000">+    A string of raw data.  This will be stored in the specified storage area under the &#39;raw&#39; storage key.</span>
<span style="color: #00A000">+Default is &#39;raw&#39;.]],</span>
<span style="color: #00A000">+  storage_area = [[(Optional) The storage area to store the response in.  Defaults to &#39;service&#39;.]],</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #000080; font-weight: bold">diff --git a/hunmonk/jester/modules/service/service.lua b/hunmonk/jester/modules/service/service.lua</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..b4190d5</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/hunmonk/jester/modules/service/service.lua</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,91 @@</span>
<span style="color: #00A000">+module(..., package.seeall)</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+--[[</span>
<span style="color: #00A000">+  Log to the console.</span>
<span style="color: #00A000">+]]</span>
<span style="color: #00A000">+function http_request(action)</span>
<span style="color: #00A000">+  local server = action.server or &quot;localhost&quot;</span>
<span style="color: #00A000">+  local port = action.port or &quot;80&quot;</span>
<span style="color: #00A000">+  local path = action.path or &quot;/&quot;</span>
<span style="color: #00A000">+  local query = action.query</span>
<span style="color: #00A000">+  local fragment = action.fragment or &quot;&quot;</span>
<span style="color: #00A000">+  local user = action.user</span>
<span style="color: #00A000">+  local password = action.password</span>
<span style="color: #00A000">+  local response = action.response or &quot;raw&quot;</span>
<span style="color: #00A000">+  local area = action.storage_area or &quot;service&quot;</span>
<span style="color: #00A000">+  local query_string = &quot;&quot;</span>
<span style="color: #00A000">+  local user_string = &quot;&quot;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+  local http = require(&quot;socket.http&quot;)</span>
<span style="color: #00A000">+  local url = require(&quot;socket.url&quot;)</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+  -- Transform the query params into a query string.</span>
<span style="color: #00A000">+  if path ~= &quot;/&quot; then</span>
<span style="color: #00A000">+    path = &quot;/&quot; .. path .. &quot;/&quot;</span>
<span style="color: #00A000">+  end</span>
<span style="color: #00A000">+  if query then</span>
<span style="color: #00A000">+    local query_parts = {}</span>
<span style="color: #00A000">+    for k, v in pairs(query) do</span>
<span style="color: #00A000">+      -- Escape values but not keys.</span>
<span style="color: #00A000">+      query_parts[#query_parts + 1] = k .. &quot;=&quot; .. url.escape(v)</span>
<span style="color: #00A000">+    end</span>
<span style="color: #00A000">+    query_string = &quot;?&quot; .. table.concat(query_parts, &quot;&amp;&quot;)</span>
<span style="color: #00A000">+  end</span>
<span style="color: #00A000">+  if fragment ~= &quot;&quot; then</span>
<span style="color: #00A000">+    fragment = &quot;#&quot; .. fragment</span>
<span style="color: #00A000">+  end</span>
<span style="color: #00A000">+  if user then</span>
<span style="color: #00A000">+    user_string = user</span>
<span style="color: #00A000">+    if password then</span>
<span style="color: #00A000">+      user_string = user_string .. &quot;:&quot; .. password</span>
<span style="color: #00A000">+    end</span>
<span style="color: #00A000">+    user_string = user_string .. &quot;@&quot;</span>
<span style="color: #00A000">+  end</span>
<span style="color: #00A000">+  url = &quot;http://&quot; .. user_string .. server .. &quot;:&quot; .. port .. path .. query_string .. fragment</span>
<span style="color: #00A000">+  jester.debug_log(&quot;HTTP request, URL: %s&quot;, url)</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+  local code, description, data</span>
<span style="color: #00A000">+  -- Send the request.</span>
<span style="color: #00A000">+  local body, status_code, headers, status_description = http.request(url)</span>
<span style="color: #00A000">+  -- Request succeeded.</span>
<span style="color: #00A000">+  if body then</span>
<span style="color: #00A000">+    data = body</span>
<span style="color: #00A000">+    code = status_code</span>
<span style="color: #00A000">+    description = status_description</span>
<span style="color: #00A000">+    -- Only store response data if we get a 200 OK code.</span>
<span style="color: #00A000">+    if code == 200 then</span>
<span style="color: #00A000">+      -- Store raw data.</span>
<span style="color: #00A000">+      if response == &quot;raw&quot; then</span>
<span style="color: #00A000">+        jester.set_storage(area, &quot;raw&quot;, data)</span>
<span style="color: #00A000">+      -- Data is a Lua table.</span>
<span style="color: #00A000">+      elseif response == &quot;lua&quot; then</span>
<span style="color: #00A000">+        -- Load the data string as Lua code.</span>
<span style="color: #00A000">+        local func = loadstring(data)</span>
<span style="color: #00A000">+        if func then</span>
<span style="color: #00A000">+          -- Sandbox the function to protect against malicious code.</span>
<span style="color: #00A000">+          setfenv(func, {})</span>
<span style="color: #00A000">+          local table_data = func()</span>
<span style="color: #00A000">+          -- Make sure a table was returned.</span>
<span style="color: #00A000">+          if type(table_data) == &quot;table&quot; then</span>
<span style="color: #00A000">+            for k, v in pairs(table_data) do</span>
<span style="color: #00A000">+              jester.set_storage(area, k, v)</span>
<span style="color: #00A000">+            end</span>
<span style="color: #00A000">+          else</span>
<span style="color: #00A000">+            jester.debug_log(&quot;ERROR: Returned data is not a Lua table.&quot;)</span>
<span style="color: #00A000">+          end</span>
<span style="color: #00A000">+        else</span>
<span style="color: #00A000">+          jester.debug_log(&quot;ERROR: Failed to parse response body as Lua code.&quot;)</span>
<span style="color: #00A000">+        end</span>
<span style="color: #00A000">+      end</span>
<span style="color: #00A000">+    end</span>
<span style="color: #00A000">+  -- Request failed.</span>
<span style="color: #00A000">+  else</span>
<span style="color: #00A000">+    code = &quot;error&quot;</span>
<span style="color: #00A000">+    description = status_code</span>
<span style="color: #00A000">+    data = &quot;&quot;</span>
<span style="color: #00A000">+  end</span>
<span style="color: #00A000">+  jester.set_storage(&quot;last_http_request&quot;, &quot;code&quot;, code)</span>
<span style="color: #00A000">+  jester.set_storage(&quot;last_http_request&quot;, &quot;description&quot;, description)</span>
<span style="color: #00A000">+  jester.debug_log(&quot;HTTP response, Code: %s, Description: %s, Data: %s&quot;, code, description, data)</span>
<span style="color: #00A000">+end</span>
<span style="color: #00A000">+</span>
</pre></div>
<div class="highlight"><pre>committer: Chad Phillips
comments: 
clean up help doc for record action.

<span style="color: #000080; font-weight: bold">diff --git a/hunmonk/jester/modules/record/help.lua b/hunmonk/jester/modules/record/help.lua</span>
<span style="color: #000080; font-weight: bold">index 30fd2c5..1230367 100644</span>
<span style="color: #A00000">--- a/hunmonk/jester/modules/record/help.lua</span>
<span style="color: #00A000">+++ b/hunmonk/jester/modules/record/help.lua</span>
<span style="color: #800080; font-weight: bold">@@ -24,13 +24,13 @@ The following variables/values related to the recording are put into Jester stor</span>
 jester.help_map.record.actions.record.params = {
   filename = [[(Optional) The name of the recorded file.  Defaults to %Y-%m-%d_%H:%M:%S-${uuid}.wav]],
   location = [[(Optional) Where to store the file.  Default is /tmp.]],
<span style="color: #A00000">-  append = [[(Optional) Append the recording to an existing file.  Requires that the &#39;name&#39; parameter be set.  If the named file does not exist, then it will be created.  Default is false.]],</span>
<span style="color: #00A000">+  append = [[(Optional) Append the recording to an existing file.  Requires that the &#39;filename&#39; parameter be set.  If the named file does not exist, then it will be created.  Default is false.]],</span>
   pre_record_sound = [[(Optional) Set to a file or phrase to play prior to beginning the recording, or to &#39;tone&#39; to play a typical &#39;wait for the beep&#39; tone.  Default is to do nothing.]],
   pre_record_delay = [[(Optional) Set to the number of milliseconds to delay just prior to beginning the recording.  This happens after the pre_record_sound is played.  This can be useful to tweak if trailing channel sounds are being recording at the beginning of the recording.  Set to 0 for no delay.  Default is 200 milliseconds.]],
   max_length = [[(Optional) Maximum allowed length of the recording in seconds.  Default is 180.]],
   silence_threshold = [[(Optional) A number indicating the threshhold for what is considered silence.  Higher numbers mean more noise will be tolerated.  Default is 20.  TODO: need to find doc on this.]],
   silence_secs = [[(Optional) The number of consecutive seconds of silence to wait before considering the recording finished.  Default is 5.]],
<span style="color: #A00000">-  storage_area = [[(Optional) If set the &#39;last_recording&#39; storage values are also stored this storage area with the &#39;last_recording_&#39; prefix stripped, eg. &#39;storage_area = &quot;message&quot;&#39; would store &#39;name&#39; in the &#39;message&#39; storage area with the same value as &#39;last_recording_name&#39;.]],</span>
<span style="color: #00A000">+  storage_area = [[(Optional) If set the &#39;last_recording&#39; storage values are also stored in this storage area with the &#39;last_recording_&#39; prefix stripped, eg. &#39;storage_area = &quot;message&quot;&#39; would store &#39;name&#39; in the &#39;message&#39; storage area with the same value as &#39;last_recording_name&#39;.]],</span>
   keys = [[(Optional) See &#39;help sequences keys&#39;.]],
 }
 
</pre></div>
========================================================================<pre>

Summary of changes:
 hunmonk/jester/conf.lua                    |    1 +
 hunmonk/jester/modules/record/help.lua     |    4 +-
 hunmonk/jester/modules/service/conf.lua    |    5 ++
 hunmonk/jester/modules/service/help.lua    |   39 ++++++++++++
 hunmonk/jester/modules/service/service.lua |   91 ++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+), 2 deletions(-)
 create mode 100644 hunmonk/jester/modules/service/conf.lua
 create mode 100644 hunmonk/jester/modules/service/help.lua
 create mode 100644 hunmonk/jester/modules/service/service.lua
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH user-contributed scripts, etc</p>