serial id

This commit is contained in:
shocknet-justin 2026-03-02 15:01:12 -05:00
parent be6f48427f
commit cfb7dd1e6e
No known key found for this signature in database
2 changed files with 15 additions and 4 deletions

View file

@ -176,6 +176,11 @@ export default class {
this.log("Deleting", toDelete.length, "inactive users")
for (let i = 0; i < toDelete.length; i++) {
const { userId, appUserIds } = toDelete[i]
const user = await this.storage.userStorage.FindUser(userId)
if (!user || user.balance_sats > 0) {
if (user) this.log("Skipping user", userId, "has balance", user.balance_sats)
continue
}
this.log("Deleting user", userId, "progress", i + 1, "/", toDelete.length)
await this.storage.StartTransaction(async tx => {
for (const appUserId of appUserIds) {

View file

@ -161,10 +161,16 @@ export default class {
this.dbs.Remove<User>('User', baseUser, txId)
}
async RemoveAppUsersAndBaseUsers(appUserIds: string[],baseUser:string, txId?: string) {
await this.dbs.Delete<ApplicationUser>('ApplicationUser', { identifier: In(appUserIds) }, txId)
await this.dbs.Delete<User>('User', { user_id: baseUser }, txId)
async RemoveAppUsersAndBaseUsers(appUserIds: string[], baseUser: string, txId?: string) {
if (appUserIds.length > 0) {
const appUsers = await this.dbs.Find<ApplicationUser>('ApplicationUser', { where: { identifier: In(appUserIds) } }, txId)
for (const appUser of appUsers) {
await this.dbs.Delete<ApplicationUser>('ApplicationUser', appUser.serial_id, txId)
}
}
const user = await this.userStorage.FindUser(baseUser, txId)
if (!user) return
await this.dbs.Delete<User>('User', user.serial_id, txId)
}