diff --git a/src/services/storage/applicationStorage.ts b/src/services/storage/applicationStorage.ts index 77438ee3..dba5b466 100644 --- a/src/services/storage/applicationStorage.ts +++ b/src/services/storage/applicationStorage.ts @@ -1,5 +1,5 @@ import crypto from 'crypto'; -import { Between, FindOperator, IsNull, LessThanOrEqual, MoreThanOrEqual, In } from "typeorm" +import { Between, FindOperator, IsNull, LessThanOrEqual, MoreThanOrEqual } from "typeorm" import { generateSecretKey, getPublicKey } from 'nostr-tools'; import { Application } from "./entity/Application.js" import UserStorage from './userStorage.js'; @@ -162,15 +162,15 @@ export default class { } async RemoveAppUsersAndBaseUsers(appUserIds: string[], baseUser: string, txId?: string) { - if (appUserIds.length > 0) { - const appUsers = await this.dbs.Find('ApplicationUser', { where: { identifier: In(appUserIds) } }, txId) - for (const appUser of appUsers) { - await this.dbs.Delete('ApplicationUser', appUser.serial_id, txId) + for (const appUserId of appUserIds) { + const appUser = await this.dbs.FindOne('ApplicationUser', { where: { identifier: appUserId } }, txId) + if (appUser) { + await this.dbs.Delete('ApplicationUser', { serial_id: appUser.serial_id }, txId) } } const user = await this.userStorage.FindUser(baseUser, txId) if (!user) return - await this.dbs.Delete('User', user.serial_id, txId) + await this.dbs.Delete('User', { serial_id: user.serial_id }, txId) } diff --git a/src/services/storage/paymentStorage.ts b/src/services/storage/paymentStorage.ts index 092ef8df..16f17f75 100644 --- a/src/services/storage/paymentStorage.ts +++ b/src/services/storage/paymentStorage.ts @@ -144,7 +144,7 @@ export default class { } let deleted = 0 for (const invoice of invoices) { - deleted += await this.dbs.Delete('UserReceivingInvoice', invoice.serial_id, txId) + deleted += await this.dbs.Delete('UserReceivingInvoice', { serial_id: invoice.serial_id }, txId) } return deleted } @@ -336,7 +336,7 @@ export default class { } let deleted = 0 for (const key of keys) { - deleted += await this.dbs.Delete('UserEphemeralKey', key.serial_id, txId) + deleted += await this.dbs.Delete('UserEphemeralKey', { serial_id: key.serial_id }, txId) } return deleted }