summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-12 09:41:55 +0100
committerspag <spag@golwen.net>2013-02-12 09:41:55 +0100
commit0ece4561627130eceb83deef4e5c2df00ec1664e (patch)
treef4e62ff18ac251bd813499ba54ecff818bb03a4e
parent8e55bf891a0520ba241585d8295ccc37ed57b09e (diff)
support for registrations to non default profiles
-rw-r--r--misc/freeswitch/scripts/common/sip_account.lua8
-rw-r--r--misc/freeswitch/scripts/configuration.lua2
-rw-r--r--misc/freeswitch/scripts/dialplan/sip_call.lua36
3 files changed, 28 insertions, 18 deletions
diff --git a/misc/freeswitch/scripts/common/sip_account.lua b/misc/freeswitch/scripts/common/sip_account.lua
index 8dd432b..d023f20 100644
--- a/misc/freeswitch/scripts/common/sip_account.lua
+++ b/misc/freeswitch/scripts/common/sip_account.lua
@@ -38,8 +38,12 @@ function SipAccount.find_by_sql(self, where)
`a`.`sip_accountable_id`, \
`a`.`hotdeskable`, \
`a`.`gs_node_id`, \
- `b`.`host` \
- FROM `sip_accounts` `a` JOIN `sip_domains` `b` ON `a`.`sip_domain_id` = `b`.`id` \
+ `b`.`host`, \
+ `c`.`sip_host`, \
+ `c`.`profile_name` \
+ FROM `sip_accounts` `a` \
+ JOIN `sip_domains` `b` ON `a`.`sip_domain_id` = `b`.`id` \
+ LEFT JOIN `sip_registrations` `c` ON `a`.`auth_name` = `c`.`sip_user` \
WHERE ' .. where .. ' LIMIT 1';
local sip_account = nil;
diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua
index 9847cc9..75d0df3 100644
--- a/misc/freeswitch/scripts/configuration.lua
+++ b/misc/freeswitch/scripts/configuration.lua
@@ -415,7 +415,7 @@ function directory_sip_account(database)
end
else
require 'common.sip_account'
- local sip_account = common.sip_account.SipAccount:new{ log = log, database = database}:find_by_auth_name(auth_name, domain);
+ local sip_account = common.sip_account.SipAccount:new{ log = log, database = database}:find_by_auth_name(auth_name);
require 'common.configuration_table'
local user_parameters = common.configuration_table.get(database, 'sip_accounts', 'parameters');
diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua
index 61d4f76..b56f1b2 100644
--- a/misc/freeswitch/scripts/dialplan/sip_call.lua
+++ b/misc/freeswitch/scripts/dialplan/sip_call.lua
@@ -116,23 +116,29 @@ function SipCall.fork(self, destinations, arg )
elseif destination.type == 'sipaccount' then
local callee_id_params = '';
local sip_account = sip_account_class:find_by_id(destination.id);
- local call_waiting = self:call_waiting_busy(sip_account);
- if not call_waiting then
- destinations[index].numbers = sip_account:phone_numbers();
+ if not sip_account then
+ self.log:notice('FORK - sip_account not found - sip_account=', destination.id);
+ elseif common.str.blank(sip_account.record.profile_name) or common.str.blank(sip_account.record.sip_host) then
+ call_result = { code = 480, phrase = 'User offline', disposition = 'USER_NOT_REGISTERED' };
+ else
+ local call_waiting = self:call_waiting_busy(sip_account);
+ if not call_waiting then
+ destinations[index].numbers = sip_account:phone_numbers();
- if not arg.callee_id_name then
- table.insert(origination_variables, "effective_callee_id_name='" .. sip_account.record.caller_name .. "'");
- end
- if not arg.callee_id_number then
- table.insert(origination_variables, "effective_callee_id_number='" .. destination.number .. "'");
- end
- if destination.alert_info then
- table.insert(origination_variables, "alert_info='" .. destination.alert_info .. "'");
+ if not arg.callee_id_name then
+ table.insert(origination_variables, "effective_callee_id_name='" .. sip_account.record.caller_name .. "'");
+ end
+ if not arg.callee_id_number then
+ table.insert(origination_variables, "effective_callee_id_number='" .. destination.number .. "'");
+ end
+ if destination.alert_info then
+ table.insert(origination_variables, "alert_info='" .. destination.alert_info .. "'");
+ end
+ table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/' .. sip_account.record.profile_name .. '/' .. sip_account.record.auth_name .. '%' .. sip_account.record.sip_host);
+ else
+ some_destinations_busy = true;
+ call_result = { code = 486, phrase = 'User busy', disposition = 'USER_BUSY' };
end
- table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']user/' .. sip_account.record.auth_name);
- else
- some_destinations_busy = true;
- call_result = { code = 486, phrase = 'User busy', disposition = 'USER_BUSY' };
end
elseif destination.type == 'gateway' then
require 'common.gateway'