diff options
-rw-r--r-- | app/controllers/trigger_controller.rb | 12 | ||||
-rw-r--r-- | app/views/users/show.html.haml | 6 | ||||
-rw-r--r-- | misc/freeswitch/scripts/http_request.lua | 7 | ||||
-rw-r--r-- | misc/freeswitch/scripts/send_fax.lua | 49 |
4 files changed, 52 insertions, 22 deletions
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index ac43832..2b491be 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -97,8 +97,16 @@ class TriggerController < ApplicationController if fax_document.save Notifications.new_fax(fax_document).deliver - File.delete("#{TMP_DIR}#{tiff_file}"); - File.delete(pdf_file); + begin + File.delete("#{TMP_DIR}#{tiff_file}"); + rescue => e + logger.error "Raw fax file could not be deleted: #{TMP_DIR}#{tiff_file} => #{e.inspect}" + end + begin + File.delete(pdf_file); + rescue => e + logger.error "PDF fax file could not be deleted: #{TMP_DIR}#{pdf_file} => #{e.inspect}" + end fax_document.tiff = nil fax_document.save fax_document.render_thumbnails diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 639a52a..c63c791 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -16,14 +16,14 @@ %tbody %tr %td - %strong= t('users.show.user_name') + ":" + %strong= truncate(t('users.show.user_name'), :length => 7) + ":" %td = truncate(@user.user_name, :length => 14) %tr %td - %strong= t('users.show.email') + ":" + %strong= truncate(t('users.show.email'), :length => 7) + ":" %td - = truncate(@user.email, :length => 14) + = mail_to @user.email, (Haml::Engine.new("%i.icon-envelope").render + ' ' + truncate(@user.email, :length => 16)) %p.controls = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @tenant, :child => @user } diff --git a/misc/freeswitch/scripts/http_request.lua b/misc/freeswitch/scripts/http_request.lua index 8acdcb6..1d6f791 100644 --- a/misc/freeswitch/scripts/http_request.lua +++ b/misc/freeswitch/scripts/http_request.lua @@ -28,4 +28,9 @@ if user and password then end local success, result, response_headers = http.request{url = url, headers = headers }; -log:debug('HTTP_REQUEST - url: ', url, ', auth: ', tostring(headers.Authorization ~= nil), ', result: ', result); + +if success then + log:debug('HTTP_REQUEST - url: ', url, ', auth: ', tostring(headers.Authorization ~= nil), ', result: ', result); +else + log:notice('HTTP_REQUEST - url: ', url, ', auth: ', tostring(headers.Authorization ~= nil), ', result: ', result); +end diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua index e3dc4cc..9b6ffce 100644 --- a/misc/freeswitch/scripts/send_fax.lua +++ b/misc/freeswitch/scripts/send_fax.lua @@ -74,25 +74,42 @@ local origination_variables = { 'gs_auth_account_uuid=' .. fax_account.record.uuid, 'gs_auth_account_type=' .. 'faxaccount', } - + +local caller = { + destination_number = destination_number, + account_type = 'faxaccount', + account_uuid = fax_account.uuid, + auth_account_type = 'faxaccount', + auth_account_uuid = fax_account.uuid, +} + +require 'dialplan.dialplan' +local dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = caller, database = database }; +local result = dialplan:retrieve_caller_data(); + +caller.caller_id_numbers = {} +if not caller.clir then + for index, number in ipairs(caller.caller_phone_numbers) do + table.insert(caller.caller_id_numbers, number); + end + caller.caller_id_name = fax_account.record.station_id; + caller.caller_id_number = caller.caller_id_numbers[1]; + table.insert(origination_variables, "sip_h_Privacy='none'"); +else + caller.caller_id_name = 'anonymous'; + caller.caller_id_number = 'anonymous'; + table.insert(origination_variables, "sip_h_Privacy='id'"); +end + +log:info('CALLER_ID_NUMBERS - clir: ', caller.clir, ', numbers: ', table.concat(caller.caller_id_numbers, ',')); + local session = nil if phone_number then + table.insert(origination_variables, "origination_caller_id_number='" .. caller.caller_id_number .. "'"); + table.insert(origination_variables, "origination_caller_id_name='" .. caller.caller_id_name .. "'"); session = freeswitch.Session("[" .. table.concat(origination_variables, ",") .. "]loopback/" .. destination_number .. "/default"); else - local caller = { - destination_number = destination_number, - caller_id_name = fax_account.record.station_id, - account_type = 'faxaccount', - account_uuid = fax_account.uuid, - auth_account_type = 'faxaccount', - auth_account_uuid = fax_account.uuid, - } - - require 'dialplan.dialplan' - local dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = caller, database = database }; - local result = dialplan:retrieve_caller_data(); - local dialplan_router = require('dialplan.router'); local routes = dialplan_router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run('outbound'); @@ -104,8 +121,8 @@ else for index, route in ipairs(routes) do log:info('FAX_SEND - ', route.type, '=', route.id, '/', route.gateway,', number: ', route.destination_number); if route.type == 'gateway' then - table.insert(origination_variables, "origination_caller_id_number='" .. (route.caller_id_number or caller.caller_phone_numbers[1]) .. "'"); - table.insert(origination_variables, "origination_caller_id_name='" .. (route.caller_id_name or fax_account.record.station_id) .. "'"); + table.insert(origination_variables, "origination_caller_id_number='" .. (route.caller_id_number or caller.caller_id_number) .. "'"); + table.insert(origination_variables, "origination_caller_id_name='" .. (route.caller_id_name or caller.caller_id_name) .. "'"); session = freeswitch.Session('[' .. table.concat(origination_variables, ',') .. ']sofia/gateway/' .. route.gateway .. '/' .. route.destination_number); log:notice('SESSION: ', session); break; |