From 4569d84c2dc8855117495e7f44c0c209be78df75 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 22 Sep 2022 17:19:34 +0200
Subject: [PATCH] publish: log

generated from commit 85d224535b4ebce0262c96e8d86056f1126c9127
---
 index.js           | 5 ++++-
 onDeleteAccount.js | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 336db81..9aa2fa0 100644
--- a/index.js
+++ b/index.js
@@ -228525,7 +228525,10 @@ async function saveAccountData(accountId, accountData) {
 async function getAccount(accountId) {
   log('info', `getAccount: ${accountId}`)
   const accounts = await cozyClient.data.findAll('io.cozy.accounts')
-  return accounts.filter(account => account.account_type === accountId)[0]
+  log('info', `getAccount: ${JSON.stringify(accounts)}`)
+  return accounts.filter(account =>
+    isLocal() ? account._id === accountId : account.account_type === accountId
+  )[0]
 }
 
 module.exports = { getAccount, saveAccountData }
diff --git a/onDeleteAccount.js b/onDeleteAccount.js
index e8dd0b7..1008f4f 100644
--- a/onDeleteAccount.js
+++ b/onDeleteAccount.js
@@ -227426,7 +227426,10 @@ async function saveAccountData(accountId, accountData) {
 async function getAccount(accountId) {
   log('info', `getAccount: ${accountId}`)
   const accounts = await cozyClient.data.findAll('io.cozy.accounts')
-  return accounts.filter(account => account.account_type === accountId)[0]
+  log('info', `getAccount: ${JSON.stringify(accounts)}`)
+  return accounts.filter(account =>
+    isLocal() ? account._id === accountId : account.account_type === accountId
+  )[0]
 }
 
 module.exports = { getAccount, saveAccountData }
-- 
GitLab