summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-12 06:55:26 -0400
committerPeter Kozak <spag@golwen.net>2013-03-12 06:55:26 -0400
commit27a3c9b2917061c8cca08ab334624cdba727745d (patch)
treee1692edc3354e891fd134b3b7a8ec449f63eb032 /misc/freeswitch/scripts
parent03a81f194a356a9228be357bad1101060af62cb1 (diff)
save last destination
Diffstat (limited to 'misc/freeswitch/scripts')
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua24
1 files changed, 15 insertions, 9 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index bbf1242..8d69a3d 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -166,16 +166,13 @@ function Dialplan.retrieve_caller_data(self)
self.caller.caller_phone_numbers_hash = {};
-- TODO: Set auth_account on transfer initiated by calling party
- if not common.str.blank(self.caller.dialed_sip_user) then
- self.caller.auth_account = self:object_find{class = 'sipaccount', domain = self.caller.dialed_domain, auth_account = self.caller.dialed_sip_user};
- if self.caller.set_auth_account then
- self.caller:set_auth_account(self.caller.auth_account);
- end
- elseif not common.str.blank(self.caller.auth_account_type) and not common.str.blank(self.caller.auth_account_uuid) then
+ if not common.str.blank(self.caller.auth_account_type) and not common.str.blank(self.caller.auth_account_uuid) then
self.caller.auth_account = self:object_find{class = self.caller.auth_account_type, uuid = self.caller.auth_account_uuid};
- if self.caller.set_auth_account then
- self.caller:set_auth_account(self.caller.auth_account);
- end
+ elseif not common.str.blank(self.caller.previous_destination_type) and not common.str.blank(self.caller.previous_destination_uuid) then
+ self.log:debug('CALLER_DATA - authenticate by previous destination: ', self.caller.previous_destination_type, '=', self.caller.previous_destination_id, '/', self.caller.previous_destination_uuid);
+ self.caller.auth_account = self:object_find{class = self.caller.previous_destination_type, uuid = self.caller.previous_destination_uuid};
+ elseif not common.str.blank(self.caller.dialed_sip_user) then
+ self.caller.auth_account = self:object_find{class = 'sipaccount', domain = self.caller.dialed_domain, auth_account = self.caller.dialed_sip_user};
end
if self.caller.auth_account then
@@ -185,6 +182,9 @@ function Dialplan.retrieve_caller_data(self)
else
self.log:error('CALLER_DATA - auth owner not found');
end
+ if self.caller.set_auth_account then
+ self.caller:set_auth_account(self.caller.auth_account);
+ end
else
self.log:info('CALLER_DATA - no data - unauthenticated call: ', self.caller.auth_account_type, '/', self.caller.auth_account_uuid);
end
@@ -315,6 +315,9 @@ function Dialplan.dial(self, destination)
for index=1, #group_ids do
table.insert(destination.pickup_groups, 'g' .. group_ids[index]);
end
+ self.caller:set_variable('gs_destination_type', destination.account.class);
+ self.caller:set_variable('gs_destination_id', destination.account.id);
+ self.caller:set_variable('gs_destination_uuid', destination.account.uuid);
end
if destination.account and destination.account.owner then
@@ -325,6 +328,9 @@ function Dialplan.dial(self, destination)
elseif destination.account.owner.class == 'tenant' then
tenant_id = destination.account.owner.id;
end
+ self.caller:set_variable('gs_destination_owner_type', destination.account.owner.class);
+ self.caller:set_variable('gs_destination_owner_id', destination.account.owner.id);
+ self.caller:set_variable('gs_destination_owner_uuid', destination.account.owner.uuid);
end
end