From 22bf9f81bf5d06cb195a89e168f0980deb23c5d0 Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Wed, 8 Jan 2025 16:13:38 +0000 Subject: [PATCH] MT#61843 Create call forward bugfix Our tests have caught a weird behaviour for the endpoint /cfdestinationsets v1 (mr11.5). The endpoint returns an empty body after creating a new destination set. This has been fixed by the backend team for versions mr12.5 onward. To fix the problem in mr11.5 we add an extra GET request to retrieve the new destination set, before patching the mapping with the updated info. NGCP-Flow: mr11.5 Change-Id: I3b42ce6682d4b51adea17e6d6bf7a0dd3cbb7860 (cherry picked from commit d9089dff4995348645eb7ce9fdad47a81faf53be) --- src/api/call-forwarding.js | 14 ++++++++++++++ src/store/call-forwarding/actions.js | 27 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/api/call-forwarding.js b/src/api/call-forwarding.js index a846c4ef..c1feebbb 100644 --- a/src/api/call-forwarding.js +++ b/src/api/call-forwarding.js @@ -24,6 +24,20 @@ export async function cfLoadDestinationSets (subscriberId) { }) } +export async function cfGetMostRecentDestinationSetByName (params) { + const res = await getList({ + resource: 'cfdestinationsets', + params: { + name: params.name, + subscriber_id: params.subscriberId, + order_by: 'id', + order_by_direction: 'desc' + } + }) + + return res.items[0] +} + export async function cfLoadSourceSets (subscriberId) { return getList({ resource: 'cfsourcesets', diff --git a/src/store/call-forwarding/actions.js b/src/store/call-forwarding/actions.js index 68522174..30f236c1 100644 --- a/src/store/call-forwarding/actions.js +++ b/src/store/call-forwarding/actions.js @@ -1,4 +1,5 @@ import { + cfCreateDestinationSet, cfCreateOfficeHours, cfCreateSourceSet, cfCreateTimeSetDate, @@ -7,6 +8,7 @@ import { cfDeleteDestinationSet, cfDeleteSourceSet, cfDeleteTimeSet, + cfGetMostRecentDestinationSetByName, cfLoadDestinationSets, cfLoadMappingsFull, cfLoadSourceSets, @@ -61,22 +63,27 @@ export async function loadMappingsFull ({ dispatch, commit, rootGetters }, subsc export async function createMapping ({ dispatch, commit, state, rootGetters }, payload) { dispatch('wait/start', WAIT_IDENTIFIER, { root: true }) + const name = 'csc-' + v4() + const subscriberId = (payload.subscriberId) ? (payload.subscriberId) : rootGetters['user/getSubscriberId'] + + await cfCreateDestinationSet({ + name, + subscriber_id: subscriberId, + destinations: [createDefaultDestination()] + }) + + const destinationSet = await cfGetMostRecentDestinationSetByName({ + name, + subscriberId: subscriberId + }) + let type = payload.type if (payload.type === 'cfu' && state.mappings.cft && state.mappings.cft.length > 0) { type = 'cft' } - const subscriberId = (payload.subscriberId) ? (payload.subscriberId) : rootGetters['user/getSubscriberId'] const mappings = _.cloneDeep(state.mappings[type]) - const destinationSetId = await post({ - resource: 'cfdestinationsets', - body: { - name: 'csc-' + v4(), - subscriber_id: subscriberId, - destinations: [createDefaultDestination()] - } - }) mappings.push({ - destinationset_id: destinationSetId + destinationset_id: destinationSet.id }) const res = await Promise.all([ patchReplaceFull({