From 5a200b7af13e23b62425c37edc28dfda63715b72 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Tue, 27 Sep 2022 10:15:44 +0200
Subject: [PATCH] publish: feat: add TU

generated from commit eb69b49183ce34435e88cdfbd123bd4040e08aeb
---
 index.js           | 14 +++++---------
 onDeleteAccount.js | 17 +++++++----------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/index.js b/index.js
index d87a6e9..24e6273 100644
--- a/index.js
+++ b/index.js
@@ -169,12 +169,11 @@ async function start(fields, cozyParameters) {
     )
     // Save bo id into account
     const accountData = await getAccount(ACCOUNT_ID)
-    const savedACCOUNT = await saveAccountData(this.accountId, {
+
+    await saveAccountData(this.accountId, {
       ...accountData.data,
       consentId: consent.ID,
-      expirationDate: contractEndDate,
     })
-    log('warn', `SAVEDD ACOUNTT${JSON.stringify(savedACCOUNT)}`)
   } else {
     log('info', 'Alternate start...')
     const accountData = await getAccount(ACCOUNT_ID)
@@ -228561,14 +228560,11 @@ function isLocal() {
  * Verify if it's an alpha URL
  * @returns {boolean}
  */
-function isDev() {
-  return (
-    process.env.COZY_URL.includes('alpha') ||
-    process.env.COZY_URL.includes('cozy.tools')
-  )
+function isAlpha() {
+  return process.env.COZY_URL.includes('alpha')
 }
 
-module.exports = { isLocal, isDev }
+module.exports = { isLocal, isAlpha }
 
 
 /***/ })
diff --git a/onDeleteAccount.js b/onDeleteAccount.js
index 4c0c6af..b77b00b 100644
--- a/onDeleteAccount.js
+++ b/onDeleteAccount.js
@@ -227461,14 +227461,11 @@ function isLocal() {
  * Verify if it's an alpha URL
  * @returns {boolean}
  */
-function isDev() {
-  return (
-    process.env.COZY_URL.includes('alpha') ||
-    process.env.COZY_URL.includes('cozy.tools')
-  )
+function isAlpha() {
+  return process.env.COZY_URL.includes('alpha')
 }
 
-module.exports = { isLocal, isDev }
+module.exports = { isLocal, isAlpha }
 
 
 /***/ }),
@@ -227489,7 +227486,8 @@ const moment = __webpack_require__(1373)
 __webpack_require__(1510)
 moment.locale('fr') // set the language
 moment.tz.setDefault('Europe/Paris') // set the timezone
-const { isLocal, isDev } = __webpack_require__(1605)
+const { isLocal, isAlpha } = __webpack_require__(1605)
+// const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon'
 
 async function onDeleteAccount() {
   log('info', 'Deleting account ...')
@@ -227512,14 +227510,13 @@ async function onDeleteAccount() {
       })
     }
     const secrets = getAccountSecret()
-    log('warn', `Account DATAA InOndelete ${JSON.stringify(accountData)}`)
     const userConsent = await getBoConsent(
       secrets.boBaseUrl,
       secrets.boToken,
       accountData.data.consentId
     )
 
-    log('info', `isAlpha: ${isDev()}`)
+    log('info', `isAlpha: ${isAlpha()}`)
     log('info', `userConsent: ${JSON.stringify(userConsent)}`)
     if (userConsent.ID && userConsent.pointID) {
       log('log', `Consent ${userConsent.ID} found for user`)
@@ -227530,7 +227527,7 @@ async function onDeleteAccount() {
           userConsent.ID
         )
         // Verify if it's dev env to prevent delete of real data
-        if (!isDev()) {
+        if (!isAlpha()) {
           await terminateContract(
             secrets.wso2BaseUrl,
             secrets.apiToken,
-- 
GitLab