From bb3293eb3ac4ac4a10d818162a42f8d9d74df624 Mon Sep 17 00:00:00 2001 From: Furkan Bilgin Date: Wed, 18 Sep 2024 18:18:36 +0300 Subject: [PATCH] fix(backend): add incoming http tokens only if the array contains them --- .../src/payment-method/ilp/peer/service.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/payment-method/ilp/peer/service.ts b/packages/backend/src/payment-method/ilp/peer/service.ts index 04ecc26283..a2a420644e 100644 --- a/packages/backend/src/payment-method/ilp/peer/service.ts +++ b/packages/backend/src/payment-method/ilp/peer/service.ts @@ -225,14 +225,16 @@ async function updatePeer( return await Peer.transaction(deps.knex, async (trx) => { if (options.http?.incoming) { await deps.httpTokenService.deleteByPeer(options.id, trx) - const err = await addIncomingHttpTokens({ - deps, - peerId: options.id, - tokens: options.http?.incoming?.authTokens, - trx - }) - if (err) { - throw err + if (options.http?.incoming?.authTokens.length > 0) { + const err = await addIncomingHttpTokens({ + deps, + peerId: options.id, + tokens: options.http?.incoming?.authTokens, + trx + }) + if (err) { + throw err + } } } return await Peer.query(trx)