From 3b5cfc5d02ad8b3a281573184ce50555a47b54bf Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:36:59 +0900 Subject: [PATCH] =?UTF-8?q?enhance:=20=E5=A4=89=E6=9B=B4=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=83=97=E3=83=AD=E3=83=91?= =?UTF-8?q?=E3=83=86=E3=82=A3=E3=82=92=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/server/api/endpoints/i/update.ts | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index cb0455862c..d684b43daf 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -477,15 +477,33 @@ export default class extends Endpoint { // eslint- this.hashtagService.updateUsertags(user, tags); //#endregion - if (Object.keys(updates).length > 0) { - await this.usersRepository.update(user.id, updates); + //#region 変更されていないプロパティを削除 + const _updates = getObjKeys(updates).reduce>((acc, key) => { + if (updates[key] != null && updates[key] !== user[key]) { + (acc[key] as MiUser[typeof key]) = updates[key]; + } + return acc; + }, {}); + + const _profileUpdates = getObjKeys(profileUpdates).reduce>((acc, key) => { + if (profileUpdates[key] != null && profileUpdates[key] !== profile[key]) { + (acc[key] as MiUserProfile[typeof key]) = profileUpdates[key]; + } + return acc; + }, {}); + //#endregion + + if (Object.keys(_updates).length > 0) { + await this.usersRepository.update(user.id, _updates); this.globalEventService.publishInternalEvent('localUserUpdated', { id: user.id }); } - await this.userProfilesRepository.update(user.id, { - ...profileUpdates, - verifiedLinks: [], - }); + if (Object.keys(_profileUpdates).length > 0 || profile.verifiedLinks.length > 0) { + await this.userProfilesRepository.update(user.id, { + ..._profileUpdates, + verifiedLinks: [], + }); + } const iObj = await this.userEntityService.pack(user.id, user, { schema: 'MeDetailed', @@ -506,8 +524,8 @@ export default class extends Endpoint { // eslint- // 連合する必要があるプロパティが変更されている場合はフォロワーにUpdateを配信 if ( - miLocalUserKeysUsedForApPersonRender.some(k => getObjKeys(updates).includes(k)) || - miUserProfileKeysUsedForApPersonRender.some(k => getObjKeys(profileUpdates).includes(k)) + miLocalUserKeysUsedForApPersonRender.some(k => getObjKeys(_updates).includes(k)) || + miUserProfileKeysUsedForApPersonRender.some(k => getObjKeys(_profileUpdates).includes(k)) ) { this.accountUpdateService.publishToFollowers(user.id); }