From 9ce67a2d462794238555c707e6d4bd5837b97047 Mon Sep 17 00:00:00 2001 From: John Corser Date: Thu, 3 Feb 2022 12:56:19 -0500 Subject: [PATCH] fix: allow pinpoint category removal after manual deletion --- .../lib/channel-Email.js | 14 ++++++++++++-- .../lib/pinpoint-helper.js | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/amplify-category-notifications/lib/channel-Email.js b/packages/amplify-category-notifications/lib/channel-Email.js index b548bb9a068..3871f9aad30 100644 --- a/packages/amplify-category-notifications/lib/channel-Email.js +++ b/packages/amplify-category-notifications/lib/channel-Email.js @@ -77,7 +77,12 @@ async function enable(context, successMessage) { spinner.start('Updating Email Channel.'); return new Promise((resolve, reject) => { context.exeInfo.pinpointClient.updateEmailChannel(params, (err, data) => { - if (err) { + if (err && err.code === 'NotFoundException') { + spinner.succeed(`Project with ID '${params.ApplicationId}' was already deleted from the cloud.`); + resolve({ + id: params.ApplicationId, + }); + } else if (err) { spinner.fail('update channel error'); reject(err); } else { @@ -112,7 +117,12 @@ async function disable(context) { spinner.start('Updating Email Channel.'); return new Promise((resolve, reject) => { context.exeInfo.pinpointClient.updateEmailChannel(params, (err, data) => { - if (err) { + if (err && err.code === 'NotFoundException') { + spinner.succeed(`Project with ID '${params.ApplicationId}' was already deleted from the cloud.`); + resolve({ + id: params.ApplicationId, + }); + } else if (err) { spinner.fail('update channel error'); reject(err); } else { diff --git a/packages/amplify-category-notifications/lib/pinpoint-helper.js b/packages/amplify-category-notifications/lib/pinpoint-helper.js index a0c5a98fd8b..7ee7dedb907 100644 --- a/packages/amplify-category-notifications/lib/pinpoint-helper.js +++ b/packages/amplify-category-notifications/lib/pinpoint-helper.js @@ -220,7 +220,12 @@ async function deleteApp(context, pinpointAppId) { spinner.start('Deleting Pinpoint app.'); return new Promise((resolve, reject) => { pinpointClient.deleteApp(params, (err, data) => { - if (err) { + if (err && err.code === 'NotFoundException') { + spinner.succeed(`Project with ID '${params.ApplicationId}' was already deleted from the cloud.`); + resolve({ + Id: params.ApplicationId, + }); + } else if (err) { spinner.fail('Pinpoint project deletion error'); reject(err); } else {