diff --git a/src/services/main/adminManager.ts b/src/services/main/adminManager.ts index d605dbe6..e0639547 100644 --- a/src/services/main/adminManager.ts +++ b/src/services/main/adminManager.ts @@ -391,7 +391,7 @@ export class AdminManager { liquidityProviders.push(liquidityEntry) } } - const usersBalance = await this.storage.paymentStorage.GetTotalUsersBalance() + const usersBalance = await this.storage.paymentStorage.GetTotalUsersBalance(true) return { users_balance: usersBalance, lnds, diff --git a/src/services/main/appUserManager.ts b/src/services/main/appUserManager.ts index e1db3637..2a2ade08 100644 --- a/src/services/main/appUserManager.ts +++ b/src/services/main/appUserManager.ts @@ -132,7 +132,7 @@ export default class { } this.log("Found", toDelete.length, "inactive users to delete") - // await this.RemoveUsers(toDelete) + await this.LockUsers(toDelete.map(u => u.userId)) } async CleanupNeverActiveUsers() { @@ -161,7 +161,15 @@ export default class { } this.log("Found", toDelete.length, "never active users to delete") - // await this.RemoveUsers(toDelete) TODO: activate deletion + await this.RemoveUsers(toDelete) + } + + async LockUsers(toLock: string[]) { + this.log("Locking", toLock.length, "users") + for (const userId of toLock) { + await this.storage.userStorage.BanUser(userId) + } + this.log("Locked users") } async RemoveUsers(toDelete: { userId: string, appUserIds: string[] }[]) { diff --git a/src/services/storage/paymentStorage.ts b/src/services/storage/paymentStorage.ts index 2d5417e4..dc2ec847 100644 --- a/src/services/storage/paymentStorage.ts +++ b/src/services/storage/paymentStorage.ts @@ -452,8 +452,12 @@ export default class { } } - async GetTotalUsersBalance(txId?: string) { - const total = await this.dbs.Sum('User', "balance_sats", {}) + async GetTotalUsersBalance(excludeLocked?: boolean, txId?: string) { + const where: { locked?: boolean } = {} + if (excludeLocked) { + where.locked = false + } + const total = await this.dbs.Sum('User', "balance_sats", where, txId) return total || 0 }