summaryrefslogtreecommitdiff
path: root/misc/freeswitch
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-04 03:33:25 -0500
committerPeter Kozak <spag@golwen.net>2013-03-04 03:33:25 -0500
commit79797464f29913b18a6591cfbc2cac5b86b30777 (patch)
tree285cea76ba59db5a07814514c513068a1c3a0cf3 /misc/freeswitch
parent017198093547d5ff67a6ebfbb745b8fd09992c87 (diff)
pickup group dialplan function honors permissions
Diffstat (limited to 'misc/freeswitch')
-rw-r--r--misc/freeswitch/scripts/dialplan/functions.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua
index 0d15b86..e9f9962 100644
--- a/misc/freeswitch/scripts/dialplan/functions.lua
+++ b/misc/freeswitch/scripts/dialplan/functions.lua
@@ -179,7 +179,20 @@ function Functions.group_pickup(self, caller, group_id)
if not tonumber(group_id) then
return { continue = false, code = 505, phrase = 'Incompatible destination', no_cdr = true };
end
-
+
+ require 'common.str';
+ require 'common.group';
+ local group_class = common.group.Group:new{ log = self.log, database = self.database };
+ local group_ids = group_class:combine(common.str.try(caller, 'auth_account.group_ids'), common.str.try(caller, 'auth_account.owner.group_ids'));
+ local target_groups = group_class:permission_targets(group_ids, 'pickup');
+
+ if not target_groups[group_id] then
+ self.log:notice('FUNCTION_GROUP_PICKUP - group=', group_id, ' not found or insufficient permissions');
+ return { continue = false, code = 401, phrase = '"Insufficient permissions', no_cdr = true };
+ end
+
+ self.log:notice('FUNCTION_GROUP_PICKUP - group=', group_id, '|', target_groups[group_id]);
+
caller:set_variable('gs_pickup_group_pick', 'g' .. group_id);
caller:execute('pickup', 'g' .. group_id);