Browse Source

UI-3374: Purge vmbox module from user callflow if not found (#140)

4.3
Guillermo Gutiérrez 7 years ago
committed by GitHub
parent
commit
8bc333d1b6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 19 deletions
  1. +70
    -16
      submodules/users/users.js
  2. +4
    -3
      submodules/vmboxes/vmboxes.js

+ 70
- 16
submodules/users/users.js View File

@ -4417,17 +4417,30 @@ define(function(require) {
});
},
usersGetVMBox: function(vmboxId, callback) {
/**
* Creates a Voicemail Box
* @param {Object} args
* @param {Object} args.data Data to be sent by the SDK to the API
* @param {Object} args.data.voicemailId Voicemail box ID
* @param {Boolean} [args.data.generateError] Whether or not to display the generic
* Monster UI error dialog when the request
* fails.
* @param {Function} [args.success] Success callback
* @param {Function} [args.error] Error callback
*/
usersGetVMBox: function(args) {
var self = this;
self.callApi({
resource: 'voicemail.get',
data: {
accountId: self.accountId,
voicemailId: vmboxId
},
data: _.merge({
accountId: self.accountId
}, args.data),
success: function(data) {
callback(data.data);
_.has(args, 'success') && args.success(data.data);
},
error: function(parsedError, error, globalHandler) {
_.has(args, 'error') && args.error(parsedError, error, globalHandler);
}
});
},
@ -5520,8 +5533,13 @@ define(function(require) {
return;
}
self.usersGetVMBox(vmboxLite.id, function(vmbox) {
callback(null, vmbox);
self.usersGetVMBox({
data: {
voicemailId: vmboxLite.id
},
success: function(vmbox) {
callback(null, vmbox);
}
});
}
], function(err, vmbox) {
@ -5755,18 +5773,54 @@ define(function(require) {
userMainCallflow: callflow
});
if (vmboxId) {
self.usersGetVMBox(vmboxId, function(vmbox) {
waterfallCallback(null, {
if (!vmboxId) {
waterfallCallback(null, null, {
callflow: callflow
});
return;
}
self.usersGetVMBox({
data: {
voicemailId: vmboxId,
generateError: false
},
success: function(vmbox) {
waterfallCallback(null, null, {
callflow: callflow,
vmbox: vmbox
});
});
} else {
waterfallCallback(null, {
callflow: callflow
});
},
error: function(parsedError, error, globalHandler) {
if (error.status === 404) {
waterfallCallback(null, vmboxId, {
callflow: callflow
});
} else {
globalHandler(parsedError, { generateError: true });
waterfallCallback(true);
}
}
});
},
function(vmboxIdNotFound, data, waterfallCallback) {
if (!vmboxIdNotFound) {
waterfallCallback(null, data);
return;
}
// VMBox no longer exists, so purge it from main callflow
monster.pub('voip.vmboxes.removeCallflowModule', {
callflow: data.callflow,
module: 'voicemail',
dataId: vmboxIdNotFound,
success: function() {
waterfallCallback(null, data);
},
error: function() {
waterfallCallback(true);
}
});
}
], function(err, results) {
if (err) {


+ 4
- 3
submodules/vmboxes/vmboxes.js View File

@ -9,7 +9,8 @@ define(function(require) {
requests: {},
subscribe: {
'voip.vmboxes.render': 'vmboxesRender'
'voip.vmboxes.render': 'vmboxesRender',
'voip.vmboxes.removeCallflowModule': 'vmboxesRemoveCallflowModule'
},
/* Users */
@ -560,7 +561,7 @@ define(function(require) {
callback(null);
return;
}
self.vmboxesRemoveModuleFromCallflow({
self.vmboxesRemoveCallflowModule({
callflow: userMainCallflow,
module: 'voicemail',
dataId: voicemailId,
@ -590,7 +591,7 @@ define(function(require) {
* @param {Function} [args.success] Success callback
* @param {Function} [args.error] Error callback
*/
vmboxesRemoveModuleFromCallflow: function(args) {
vmboxesRemoveCallflowModule: function(args) {
var self = this,
callflow = args.callflow,
parentFlow = callflow,


Loading…
Cancel
Save