summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2024-10-14 09:11:03 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2024-10-14 09:11:03 +0900
commit064d6ca56f66ff3061fb27897df429e534288462 (patch)
tree67e4171a4032d221cb9ea0a64c57a6f248bbd1ac
parentfix(frontend): タイムラインで、広告がない際にも広告のwrapp... (diff)
downloadmisskey-064d6ca56f66ff3061fb27897df429e534288462.tar.gz
misskey-064d6ca56f66ff3061fb27897df429e534288462.tar.bz2
misskey-064d6ca56f66ff3061fb27897df429e534288462.zip
fix(backend): RBT有効時、リノートのリアクションが反映されない問題を修正
-rw-r--r--CHANGELOG.md1
-rw-r--r--packages/backend/src/core/entities/NoteEntityService.ts27
2 files changed, 26 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 130eb00b77..22b5506f28 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@
### Server
- Feat: モデレータ権限を持つユーザが全員7日間活動しなかった場合は自動的に招待制へと移行するように ( #13437 )
- Fix: `admin/emoji/update`エンドポイントのidのみ指定した時不正なエラーが発生するバグを修正
+- Fix: RBT有効時、リノートのリアクションが反映されない問題を修正
### Server
- Fix: キューのエラーログを簡略化するように
diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts
index c64e9151a7..e530772dd9 100644
--- a/packages/backend/src/core/entities/NoteEntityService.ts
+++ b/packages/backend/src/core/entities/NoteEntityService.ts
@@ -22,6 +22,29 @@ import type { ReactionService } from '../ReactionService.js';
import type { UserEntityService } from './UserEntityService.js';
import type { DriveFileEntityService } from './DriveFileEntityService.js';
+function isPureRenote(note: MiNote): note is MiNote & { renoteId: MiNote['id']; renote: MiNote } {
+ return (
+ note.renote != null &&
+ note.reply == null &&
+ note.text == null &&
+ note.cw == null &&
+ (note.fileIds == null || note.fileIds.length === 0) &&
+ !note.hasPoll
+ );
+}
+
+function getAppearNoteIds(notes: MiNote[]): Set<string> {
+ const appearNoteIds = new Set<string>();
+ for (const note of notes) {
+ if (isPureRenote(note)) {
+ appearNoteIds.add(note.renoteId);
+ } else {
+ appearNoteIds.add(note.id);
+ }
+ }
+ return appearNoteIds;
+}
+
@Injectable()
export class NoteEntityService implements OnModuleInit {
private userEntityService: UserEntityService;
@@ -421,7 +444,7 @@ export class NoteEntityService implements OnModuleInit {
) {
if (notes.length === 0) return [];
- const bufferedReactions = this.meta.enableReactionsBuffering ? await this.reactionsBufferingService.getMany(notes.map(x => x.id)) : null;
+ const bufferedReactions = this.meta.enableReactionsBuffering ? await this.reactionsBufferingService.getMany([...getAppearNoteIds(notes)]) : null;
const meId = me ? me.id : null;
const myReactionsMap = new Map<MiNote['id'], string | null>();
@@ -432,7 +455,7 @@ export class NoteEntityService implements OnModuleInit {
const oldId = this.idService.gen(Date.now() - 2000);
for (const note of notes) {
- if (note.renote && (note.text == null && note.fileIds.length === 0)) { // pure renote
+ if (isPureRenote(note)) {
const reactionsCount = Object.values(this.reactionsBufferingService.mergeReactions(note.renote.reactions, bufferedReactions?.get(note.renote.id)?.deltas ?? {})).reduce((a, b) => a + b, 0);
if (reactionsCount === 0) {
myReactionsMap.set(note.renote.id, null);