From 0ddc79bb9127eb6de0ba5110329bf15a506a6540 Mon Sep 17 00:00:00 2001 From: Nanashia Date: Sun, 16 Apr 2023 15:23:49 +0900 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E3=82=A2=E3=83=90=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=81=A8=E3=83=90=E3=83=8A=E3=83=BC=E3=81=8C=E3=83=AA?= =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=88=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84?= =?UTF-8?q?=20(#10643)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(backend): avatar and banner couldn't be reset * Update CHANGELOG.md --- CHANGELOG.md | 1 + packages/backend/src/server/api/endpoints/i/update.ts | 8 ++++++++ packages/backend/test/e2e/users.ts | 2 -- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deb5b3e97..d0c662a54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ ### Server - Fix: エクスポートデータの拡張子がunknownになる問題を修正 - Fix: Content-Dispositionのパースでエラーが発生した場合にダウンロードが完了しない問題を修正 +- Fix: API: i/update avatarIdとbannerIdにnullを渡した時、画像がリセットされない問題を修正 ## 13.11.3 diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index be1c72b20..97699f3be 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -221,6 +221,10 @@ export default class extends Endpoint { updates.avatarId = avatar.id; updates.avatarUrl = this.driveFileEntityService.getPublicUrl(avatar, 'avatar'); updates.avatarBlurhash = avatar.blurhash; + } else if (ps.avatarId === null) { + updates.avatarId = null; + updates.avatarUrl = null; + updates.avatarBlurhash = null; } if (ps.bannerId) { @@ -232,6 +236,10 @@ export default class extends Endpoint { updates.bannerId = banner.id; updates.bannerUrl = this.driveFileEntityService.getPublicUrl(banner); updates.bannerBlurhash = banner.blurhash; + } else if (ps.bannerId === null) { + updates.bannerId = null; + updates.bannerUrl = null; + updates.bannerBlurhash = null; } if (ps.pinnedPageId) { diff --git a/packages/backend/test/e2e/users.ts b/packages/backend/test/e2e/users.ts index 444fb284b..2c4716c06 100644 --- a/packages/backend/test/e2e/users.ts +++ b/packages/backend/test/e2e/users.ts @@ -508,7 +508,6 @@ describe('ユーザー', () => { }; assert.deepStrictEqual(response, expected, inspect(parameters)); - if (1) return; // BUG 521eb95 以降アバターのリセットができない。 const parameters2 = { avatarId: null }; const response2 = await successfulApiCall({ endpoint: 'i/update', parameters: parameters2, user: alice }); const expected2 = { @@ -534,7 +533,6 @@ describe('ユーザー', () => { }; assert.deepStrictEqual(response, expected, inspect(parameters)); - if (1) return; // BUG 521eb95 以降バナーのリセットができない。 const parameters2 = { bannerId: null }; const response2 = await successfulApiCall({ endpoint: 'i/update', parameters: parameters2, user: alice }); const expected2 = {