From 416da28dc39c8b25510a4f4c5c98dc1d902f378c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Mon, 1 Apr 2024 23:18:58 +0900 Subject: [PATCH] =?UTF-8?q?fix(backend):=20Skeb=E9=80=A3=E6=90=BA=E3=81=AE?= =?UTF-8?q?=E7=85=A7=E4=BC=9A=E5=BE=8C=E3=83=AD=E3=83=BC=E3=83=AB=E4=BB=98?= =?UTF-8?q?=E4=B8=8E=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=97=E3=81=A6=E3=82=82?= =?UTF-8?q?=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/endpoints/users/get-skeb-status.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/get-skeb-status.ts b/packages/backend/src/server/api/endpoints/users/get-skeb-status.ts index f2e1036651..87782539d7 100644 --- a/packages/backend/src/server/api/endpoints/users/get-skeb-status.ts +++ b/packages/backend/src/server/api/endpoints/users/get-skeb-status.ts @@ -134,16 +134,24 @@ export default class extends Endpoint { // eslint- if (res.status > 299 || (json.error ?? json.ban_reason)) { logger.error('Skeb status response error', { url: url.href, userId: ps.userId, status: res.status, statusText: res.statusText, error: json.error ?? json.ban_reason }); - if (res.status === 404 && hasSkebRole) await this.roleService.unassign(ps.userId, this.config.skebStatus.roleId); + try { + if (res.status === 404 && hasSkebRole) await this.roleService.unassign(ps.userId, this.config.skebStatus.roleId); + } catch (err) { + logger.error('Failed to unassign role', { userId: ps.userId, roleId: this.config.skebStatus.roleId, error: err }); + } throw new ApiError(meta.errors.noSuchUser); } logger.info('Skeb status response', { url: url.href, userId: ps.userId, status: res.status, statusText: res.statusText, skebStatus: json }); - if (json.is_acceptable) { - if (!hasSkebRole) await this.roleService.assign(ps.userId, this.config.skebStatus.roleId); - } else if (hasSkebRole) { - await this.roleService.unassign(ps.userId, this.config.skebStatus.roleId); + try { + if (json.is_acceptable) { + if (!hasSkebRole) await this.roleService.assign(ps.userId, this.config.skebStatus.roleId); + } else if (hasSkebRole) { + await this.roleService.unassign(ps.userId, this.config.skebStatus.roleId); + } + } catch (err) { + logger.error('Failed to assign/unassign role', { userId: ps.userId, roleId: this.config.skebStatus.roleId, error: err }); } return {