mirror of
https://github.com/paricafe/misskey.git
synced 2024-12-01 01:46:43 -06:00
fix(backend): RBT有効時、リノートのリアクションが反映されない問題を修正
This commit is contained in:
parent
886290057e
commit
1f993c72bf
2 changed files with 26 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
- Fix: `admin/emoji/update`エンドポイントのidのみ指定した時不正なエラーが発生するバグを修正
|
- Fix: `admin/emoji/update`エンドポイントのidのみ指定した時不正なエラーが発生するバグを修正
|
||||||
|
- Fix: RBT有効時、リノートのリアクションが反映されない問題を修正
|
||||||
|
|
||||||
## 2024.10.0
|
## 2024.10.0
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,29 @@ import type { ReactionService } from '../ReactionService.js';
|
||||||
import type { UserEntityService } from './UserEntityService.js';
|
import type { UserEntityService } from './UserEntityService.js';
|
||||||
import type { DriveFileEntityService } from './DriveFileEntityService.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()
|
@Injectable()
|
||||||
export class NoteEntityService implements OnModuleInit {
|
export class NoteEntityService implements OnModuleInit {
|
||||||
private userEntityService: UserEntityService;
|
private userEntityService: UserEntityService;
|
||||||
|
@ -423,7 +446,7 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
) {
|
) {
|
||||||
if (notes.length === 0) return [];
|
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 meId = me ? me.id : null;
|
||||||
const myReactionsMap = new Map<MiNote['id'], string | null>();
|
const myReactionsMap = new Map<MiNote['id'], string | null>();
|
||||||
|
@ -434,7 +457,7 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
const oldId = this.idService.gen(Date.now() - 2000);
|
const oldId = this.idService.gen(Date.now() - 2000);
|
||||||
|
|
||||||
for (const note of notes) {
|
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);
|
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) {
|
if (reactionsCount === 0) {
|
||||||
myReactionsMap.set(note.renote.id, null);
|
myReactionsMap.set(note.renote.id, null);
|
||||||
|
|
Loading…
Reference in a new issue