TT#20650 Prevent timeout non-number destinations

Change-Id: I03f49f097efd6cdaeaf8af61aabf3382607aaabf
changes/25/15225/2
Robert Axelsen 8 years ago
parent a6290f6082
commit fc01360f13

@ -253,6 +253,8 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
if (data.destination !== 'own phone') { if (data.destination !== 'own phone') {
switch (recordsToSend.length === 0 || !me.destinationIdExistsInArray(recordsToSend, data.destinationset_id)) { switch (recordsToSend.length === 0 || !me.destinationIdExistsInArray(recordsToSend, data.destinationset_id)) {
case true: case true:
// if recordsToSend array is empty or recordsToSend does not already contain current destinationset already
if (data.timeout) {
recordsToSend.push({ recordsToSend.push({
id: data.destinationset_id, id: data.destinationset_id,
records: [{ records: [{
@ -262,16 +264,36 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
"timeout": data.timeout "timeout": data.timeout
}] }]
}); });
} else {
recordsToSend.push({
id: data.destinationset_id,
records: [{
"announcement_id": null,
"destination": data.destination,
"priority": data.priority
}]
});
};
break; break;
case false: case false:
// if destinationset has already been added to recordsToSend, push to the records field for that destinationset,
// building up an array of destination objects to write to API
recordsToSend.forEach(function(obj, index) { recordsToSend.forEach(function(obj, index) {
if (obj.id == data.destinationset_id) { if (obj.id == data.destinationset_id) {
if (data.timeout) {
recordsToSend[index].records.push({ recordsToSend[index].records.push({
"announcement_id": null, "announcement_id": null,
"destination": data.destination, "destination": data.destination,
"priority": data.priority, "priority": data.priority,
"timeout": data.timeout "timeout": data.timeout
}); });
} else {
recordsToSend[index].records.push({
"announcement_id": null,
"destination": data.destination,
"priority": data.priority
});
};
}; };
}); });
break; break;
@ -1105,10 +1127,7 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
var newTimeset = this.getTimeSetFromTimeSource(newTimesetName); var newTimeset = this.getTimeSetFromTimeSource(newTimesetName);
var newType = this.getTypeFromTypeName(newTypeName, store); var newType = this.getTypeFromTypeName(newTypeName, store);
var newDestination = destination === 'Voicemail' ? 'voicebox' : destination.toLowerCase(); var newDestination = destination === 'Voicemail' ? 'voicebox' : destination.toLowerCase();
// TODO: Sets default timeout to 10 for non-number types, as can not be var newTimeout = !timeout ? null : timeout;
// set to null. Not sure if this has any implication, so needs to be
// checked with Andreas
var newTimeout = !timeout ? '10' : timeout;
if (!store.last()) { // if store empty we need to create new destset if (!store.last()) { // if store empty we need to create new destset
var newDestinationsetName = 'csc_defined_' + newType + '_' + Date.now(); var newDestinationsetName = 'csc_defined_' + newType + '_' + Date.now();
var subscriberId = localStorage.getItem('subscriber_id'); var subscriberId = localStorage.getItem('subscriber_id');
@ -1135,15 +1154,6 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
store.add(cfModel); store.add(cfModel);
me.setLabelTerminationType(store); me.setLabelTerminationType(store);
store.sync(); store.sync();
// TODO @Robert: do we need to create new timeset/sourceset here?
// it seems to me that they have to exist already, if user is able
// to create a new destination
// Creates new sourceset/timeset if variable is not set to null
//newSourceset && me.createNewStandardSet('/api/cfsourcesets/', newSourceset, subscriberId);
//newTimeset && me.createNewStandardSet('/api/cftimesets/', newTimeset, subscriberId);
me.createNewMapping(subscriberId, newType, newDestinationsetName, newSourceset, newTimeset); me.createNewMapping(subscriberId, newType, newDestinationsetName, newSourceset, newTimeset);
}, },
failure: function(response, opts) { failure: function(response, opts) {

Loading…
Cancel
Save