diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index e598ae9..252183c 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -10,7 +10,7 @@ define(function(require){ requests: { 'strategy.callflows.listHasType': { - url: 'accounts/{accountId}/callflows?has_value=type', + url: 'accounts/{accountId}/callflows?has_value=type&key_missing=owner_id', verb: 'GET' }, 'strategy.callflows.list': { @@ -30,7 +30,7 @@ define(function(require){ verb: 'POST' }, 'strategy.callflows.listUserCallflows': { - url: 'accounts/{accountId}/callflows?has_key=owner_id&key_missing=type', + url: 'accounts/{accountId}/callflows?has_key=owner_id', verb: 'GET' }, 'strategy.callflows.listRingGroups': { @@ -2171,7 +2171,10 @@ define(function(require){ accountId: self.accountId }, success: function(data, status) { - _callback(null, data.data); + var userCallflows = _.filter(data.data, function(callflow) { + return (callflow.type === 'mainUserCallflow' || !('type' in callflow)); + }); + _callback(null, userCallflows); } }); }, diff --git a/submodules/users/users.js b/submodules/users/users.js index 73e499f..2bc8696 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -483,21 +483,8 @@ define(function(require){ }); }, userCallflow: function(callback) { - self.usersListCallflowsUser(currentUser.id, function(data) { - if(data.length > 0) { - monster.request({ - resource: 'voip.users.getCallflow', - data: { - accountId: self.accountId, - callflowId: data[0].id - }, - success: function(callflow) { - callback(null, callflow.data) - } - }); - } else { - callback(null, null); - } + self.usersGetMainCallflow(currentUser.id, function(callflow) { + callback(null, callflow); }); } }, @@ -1176,20 +1163,11 @@ define(function(require){ }); template.on('click', '.feature[data-feature="call_recording"]', function() { - self.usersListCallflowsUser(currentUser.id, function(data) { - if(data.length > 0) { - monster.request({ - resource: 'voip.users.getCallflow', - data: { - accountId: self.accountId, - callflowId: data[0].id - }, - success: function(callflow) { - self.usersRenderCallRecording({ - userCallflow: callflow.data, - currentUser: currentUser - }); - } + self.usersGetMainCallflow(currentUser.id, function(callflow) { + if(callflow) { + self.usersRenderCallRecording({ + userCallflow: callflow, + currentUser: currentUser }); } else { monster.ui.alert('error', self.i18n.active().users.call_recording.noNumber); @@ -2978,6 +2956,7 @@ define(function(require){ self.usersCreateVMBox(data.vmbox, function(_dataVM) { data.callflow.owner_id = userId; + data.callflow.type = 'mainUserCallflow'; data.callflow.flow.data.id = userId; data.callflow.flow.children['_'].data.id = _dataVM.id; @@ -3030,7 +3009,8 @@ define(function(require){ }, name: fullName + ' SmartPBX\'s Callflow', numbers: listExtensions, - owner_id: user.id + owner_id: user.id, + type: 'mainUserCallflow' }; self.usersSmartUpdateVMBox(user, false, function(_dataVM) { @@ -3063,7 +3043,7 @@ define(function(require){ var indexMain = -1; _.each(listCallflows, function(callflow, index) { - if(callflow.owner_id === userId) { + if(callflow.owner_id === userId && callflow.type === 'mainUserCallflow' || !('type' in callflow)) { indexMain = index; return false; } @@ -3256,21 +3236,6 @@ define(function(require){ }); }, - usersCreateCallflow: function(callflowData, callback) { - var self = this; - - monster.request({ - resource: 'voip.users.createCallflow', - data: { - accountId: self.accountId, - data: callflowData - }, - success: function(data) { - callback(data.data); - } - }); - }, - usersGetUser: function(userId, callback) { var self = this; @@ -3587,21 +3552,8 @@ define(function(require){ }); }; - self.usersListCallflowsUser(userId, function(data) { - if(data.length > 0) { - monster.request({ - resource: 'voip.users.getCallflow', - data: { - accountId: self.accountId, - callflowId: data[0].id - }, - success: function(callflow) { - updateDevices(callflow.data); - } - }); - } else { - updateDevices(null); - } + self.usersGetMainCallflow(userId, function(callflow) { + updateDevices(callflow) }); },