From ff355f5d8b20c2f412c426070cd18cd67b39d30f Mon Sep 17 00:00:00 2001 From: mattyatea Date: Sat, 8 Jun 2024 18:25:38 +0900 Subject: [PATCH] update --- packages/backend/src/server/api/endpoints/i.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/i.ts b/packages/backend/src/server/api/endpoints/i.ts index 2b7a1d30fe..cf8f561e55 100644 --- a/packages/backend/src/server/api/endpoints/i.ts +++ b/packages/backend/src/server/api/endpoints/i.ts @@ -82,10 +82,18 @@ export default class extends Endpoint { // eslint- this.userProfilesRepository.update({ userId: user.id }, { loggedInDates: [...userProfile.loggedInDates, today], }); - this.usersRepository.update( user.id, { - getPoints: user.getPoints + todayGetPoints, + const user_ = await this.usersRepository.findOne({ + where: { + id: user.id, + }, }); - this.notificationService.createNotification(user. id, 'loginbonus', { + if (user_ == null) { + throw new ApiError(meta.errors.userIsDeleted); + } + this.usersRepository.update( user.id, { + getPoints: user_.getPoints + todayGetPoints, + }); + this.notificationService.createNotification(user.id, 'loginbonus', { loginbonus: todayGetPoints, }); userProfile.loggedInDates = [...userProfile.loggedInDates, today];