Skip to content

Commit

Permalink
UI-1877: Fixed Find me follow me / call recording interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
JRMaitre committed Nov 18, 2015
1 parent baaf589 commit 16face6
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions submodules/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -1941,9 +1941,14 @@ define(function(require){
},
openedTab: 'features'
},
endpoints = (userCallflow.flow.module === 'ring_group' ? userCallflow.flow.data.endpoints : []),
userDevices = {};

var nodeSearch = userCallflow.flow;
while(nodeSearch.hasOwnProperty('module') && ['ring_group', 'user'].indexOf(nodeSearch.module) < 0) {
nodeSearch = nodeSearch.children['_'];
}
endpoints = nodeSearch.module === 'ring_group' ? nodeSearch.data.endpoints : [];

_.each(params.userDevices, function(val) {
userDevices[val.id] = val;
});
Expand Down Expand Up @@ -1999,31 +2004,44 @@ define(function(require){
currentUser.smartpbx.find_me_follow_me = currentUser.smartpbx.find_me_follow_me || {};
currentUser.smartpbx.find_me_follow_me.enabled = (enabled && endpoints.length > 0);

var callflowNode = {};

if(enabled && endpoints.length > 0) {
userCallflow.flow.module = 'ring_group';
userCallflow.flow.data = {
callflowNode.module = 'ring_group';
callflowNode.data = {
strategy: "simultaneous",
timeout: 20,
endpoints: []
}

_.each(endpoints, function(endpoint) {
userCallflow.flow.data.endpoints.push({
callflowNode.data.endpoints.push({
id: endpoint.id,
endpoint_type: "device",
delay: endpoint.delay,
timeout: endpoint.timeout
});

if((endpoint.delay+endpoint.timeout) > userCallflow.flow.data.timeout) { userCallflow.flow.data.timeout = (endpoint.delay+endpoint.timeout); }
if((endpoint.delay+endpoint.timeout) > callflowNode.data.timeout) {
callflowNode.data.timeout = (endpoint.delay+endpoint.timeout);
}
});
} else {
userCallflow.flow.module = 'user';
userCallflow.flow.data = {
callflowNode.module='user';
callflowNode.data = {
can_call_self: false,
id: currentUser.id,
timeout: 20
}
};
}

// In next 5 lines, look for user/group node, and replace it with the new data;
var flow = userCallflow.flow;
while(flow.hasOwnProperty('module') && ['ring_group', 'user'].indexOf(flow.module) < 0) {
flow = flow.children['_'];
}
flow.module = callflowNode.module;
flow.data = callflowNode.data;

monster.parallel({
callflow: function(callbackParallel) {
Expand Down

0 comments on commit 16face6

Please sign in to comment.