diff --git a/index.js b/index.js index 4a6177148935e2437864a26aad1c8f4c647e6816..994e3ebdca26cb8028857ad19ba48d7586adcd77 100644 --- a/index.js +++ b/index.js @@ -228522,7 +228522,15 @@ async function saveAccountData(accountId, accountData) { return account } -async function getAccount(accountId, accountRev) { +async function getAccount(accountId) { + log('info', `getAccount: ${accountId}`) + const accounts = await cozyClient.data.findAll('io.cozy.accounts') + return accounts.filter(account => + isLocal() ? account._id === accountId : account.account_type === accountId + )[0] +} + +async function getAccountForDelete(accountId, accountRev) { log('info', `getAccount: ${accountId}`) const accounts = await cozyClient.data.findAll('io.cozy.accounts') const body = await cozyClient.fetchJSON( @@ -228536,7 +228544,7 @@ async function getAccount(accountId, accountRev) { )[0] } -module.exports = { getAccount, saveAccountData } +module.exports = { getAccount, saveAccountData, getAccountForDelete } /***/ }), diff --git a/onDeleteAccount.js b/onDeleteAccount.js index 174c34e90a317bda54bc5cdf947daae53fc30b3c..8e284b6ad06773785ff2a0e3264c142d61454b66 100644 --- a/onDeleteAccount.js +++ b/onDeleteAccount.js @@ -227423,7 +227423,15 @@ async function saveAccountData(accountId, accountData) { return account } -async function getAccount(accountId, accountRev) { +async function getAccount(accountId) { + log('info', `getAccount: ${accountId}`) + const accounts = await cozyClient.data.findAll('io.cozy.accounts') + return accounts.filter(account => + isLocal() ? account._id === accountId : account.account_type === accountId + )[0] +} + +async function getAccountForDelete(accountId, accountRev) { log('info', `getAccount: ${accountId}`) const accounts = await cozyClient.data.findAll('io.cozy.accounts') const body = await cozyClient.fetchJSON( @@ -227437,7 +227445,7 @@ async function getAccount(accountId, accountRev) { )[0] } -module.exports = { getAccount, saveAccountData } +module.exports = { getAccount, saveAccountData, getAccountForDelete } /***/ }), @@ -227464,7 +227472,7 @@ const { log, errors } = __webpack_require__(1) const { getAccountRev, getAccountSecret } = __webpack_require__(1607) const { getBoConsent, deleteBoConsent } = __webpack_require__(1557) const { terminateContract } = __webpack_require__(1598) -const { getAccount } = __webpack_require__(1604) +const { getAccountForDelete } = __webpack_require__(1604) const moment = __webpack_require__(1373) __webpack_require__(1510) moment.locale('fr') // set the language @@ -227480,7 +227488,7 @@ async function onDeleteAccount() { if (accountRev) { log('info', 'Account rev exist') - const accountData = await getAccount(ACCOUNT_ID, accountRev) + const accountData = await getAccountForDelete(ACCOUNT_ID, accountRev) // Parse local info for deletion test if (isLocal()) { log('warn', 'Local run')