From f7a3f403802ef1ee2cf6ac3d3c40ae2def7fc969 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 22 Sep 2022 17:52:05 +0200
Subject: [PATCH] publish: fix

generated from commit 669cf23785d704556f1b652c8fdae0da9691a97a
---
 index.js           | 8 +++-----
 onDeleteAccount.js | 8 +++-----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index 2f0fc14..db8ed59 100644
--- a/index.js
+++ b/index.js
@@ -228531,17 +228531,15 @@ async function getAccount(accountId) {
 }
 
 async function getAccountForDelete(accountId, accountRev) {
-  log('info', `getAccountForDelete: ${accountId}`)
-  const accounts = await cozyClient.data.findAll('io.cozy.accounts')
+  log('info', `getAccountForDelete: ${accountId} ${accountRev}`)
+  // const accounts = await cozyClient.data.findAll('io.cozy.accounts')
   const body = await cozyClient.fetchJSON(
     'GET',
     `/data/io.cozy.accounts/${accountId}?rev=${accountRev}`
   )
 
   log('info', `getAccountForDelete: ${body}`)
-  return accounts.filter(account =>
-    isLocal() ? account._id === accountId : account.account_type === accountId
-  )[0]
+  return body
 }
 
 module.exports = { getAccount, saveAccountData, getAccountForDelete }
diff --git a/onDeleteAccount.js b/onDeleteAccount.js
index 53e9bcb..890e160 100644
--- a/onDeleteAccount.js
+++ b/onDeleteAccount.js
@@ -227432,17 +227432,15 @@ async function getAccount(accountId) {
 }
 
 async function getAccountForDelete(accountId, accountRev) {
-  log('info', `getAccountForDelete: ${accountId}`)
-  const accounts = await cozyClient.data.findAll('io.cozy.accounts')
+  log('info', `getAccountForDelete: ${accountId} ${accountRev}`)
+  // const accounts = await cozyClient.data.findAll('io.cozy.accounts')
   const body = await cozyClient.fetchJSON(
     'GET',
     `/data/io.cozy.accounts/${accountId}?rev=${accountRev}`
   )
 
   log('info', `getAccountForDelete: ${body}`)
-  return accounts.filter(account =>
-    isLocal() ? account._id === accountId : account.account_type === accountId
-  )[0]
+  return body
 }
 
 module.exports = { getAccount, saveAccountData, getAccountForDelete }
-- 
GitLab