summaryrefslogtreecommitdiff
path: root/packages/backend/src/core
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-08-23 17:37:15 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-08-23 17:37:15 +0900
commitbd0730e5e805840ad3cb5e0f80a212b9651a16e1 (patch)
tree74dc1b8254e92ef7e40f2840b89d594812b9bb0b /packages/backend/src/core
parentUpdate CHANGELOG with recent feature and fix entries (diff)
downloadmisskey-bd0730e5e805840ad3cb5e0f80a212b9651a16e1.tar.gz
misskey-bd0730e5e805840ad3cb5e0f80a212b9651a16e1.tar.bz2
misskey-bd0730e5e805840ad3cb5e0f80a212b9651a16e1.zip
fix(backend): 削除されたユーザーがチャットメッセージにリアクションしている場合`chat/history`などでエラーになる問題を修正
Fix #16445
Diffstat (limited to 'packages/backend/src/core')
-rw-r--r--packages/backend/src/core/entities/ChatEntityService.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/packages/backend/src/core/entities/ChatEntityService.ts b/packages/backend/src/core/entities/ChatEntityService.ts
index 6bce2413fd..cfa983e766 100644
--- a/packages/backend/src/core/entities/ChatEntityService.ts
+++ b/packages/backend/src/core/entities/ChatEntityService.ts
@@ -54,12 +54,13 @@ export class ChatEntityService {
const message = typeof src === 'object' ? src : await this.chatMessagesRepository.findOneByOrFail({ id: src });
- const reactions: { user: Packed<'UserLite'>; reaction: string; }[] = [];
+ // userは削除されている可能性があるのでnull許容
+ const reactions: { user: Packed<'UserLite'> | null; reaction: string; }[] = [];
for (const record of message.reactions) {
const [userId, reaction] = record.split('/');
reactions.push({
- user: packedUsers?.get(userId) ?? await this.userEntityService.pack(userId),
+ user: packedUsers?.get(userId) ?? await this.userEntityService.pack(userId).catch(() => null),
reaction,
});
}
@@ -76,7 +77,7 @@ export class ChatEntityService {
toRoom: message.toRoomId ? (packedRooms?.get(message.toRoomId) ?? await this.packRoom(message.toRoom ?? message.toRoomId, me)) : undefined,
fileId: message.fileId,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? await this.driveFileEntityService.pack(message.file ?? message.fileId)) : null,
- reactions,
+ reactions: reactions.filter((r): r is { user: Packed<'UserLite'>; reaction: string; } => r.user != null),
};
}
@@ -108,6 +109,7 @@ export class ChatEntityService {
}
}
+ // TODO: packedUsersに削除されたユーザーもnullとして含める
const [packedUsers, packedFiles, packedRooms] = await Promise.all([
this.userEntityService.packMany(users, me)
.then(users => new Map(users.map(u => [u.id, u]))),
@@ -183,12 +185,13 @@ export class ChatEntityService {
const message = typeof src === 'object' ? src : await this.chatMessagesRepository.findOneByOrFail({ id: src });
- const reactions: { user: Packed<'UserLite'>; reaction: string; }[] = [];
+ // userは削除されている可能性があるのでnull許容
+ const reactions: { user: Packed<'UserLite'> | null; reaction: string; }[] = [];
for (const record of message.reactions) {
const [userId, reaction] = record.split('/');
reactions.push({
- user: packedUsers?.get(userId) ?? await this.userEntityService.pack(userId),
+ user: packedUsers?.get(userId) ?? await this.userEntityService.pack(userId).catch(() => null),
reaction,
});
}
@@ -202,7 +205,7 @@ export class ChatEntityService {
toRoomId: message.toRoomId!,
fileId: message.fileId,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? await this.driveFileEntityService.pack(message.file ?? message.fileId)) : null,
- reactions,
+ reactions: reactions.filter((r): r is { user: Packed<'UserLite'>; reaction: string; } => r.user != null),
};
}