use assignMyReaction in channel, hashtag, role-timeline, and user-list channels

This commit is contained in:
Hazelnoot 2025-02-25 20:54:54 -05:00
parent 019e60d9a4
commit 30b2bfb184
4 changed files with 14 additions and 27 deletions

View file

@ -7,7 +7,6 @@ import { Injectable } from '@nestjs/common';
import type { Packed } from '@/misc/json-schema.js'; import type { Packed } from '@/misc/json-schema.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
import type { JsonObject } from '@/misc/json-value.js'; import type { JsonObject } from '@/misc/json-value.js';
import Channel, { type MiChannelService } from '../channel.js'; import Channel, { type MiChannelService } from '../channel.js';
@ -50,16 +49,11 @@ class ChannelChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return; if (this.isNoteMutedOrBlocked(note)) return;
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) { const clonedNote = await this.assignMyReaction(note);
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
note.renote.myReaction = myRenoteReaction;
}
}
this.connection.cacheNote(note); this.connection.cacheNote(clonedNote);
this.send('note', note); this.send('note', clonedNote);
} }
@bindThis @bindThis

View file

@ -8,7 +8,6 @@ import { normalizeForSearch } from '@/misc/normalize-for-search.js';
import type { Packed } from '@/misc/json-schema.js'; import type { Packed } from '@/misc/json-schema.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
import type { JsonObject } from '@/misc/json-value.js'; import type { JsonObject } from '@/misc/json-value.js';
import Channel, { type MiChannelService } from '../channel.js'; import Channel, { type MiChannelService } from '../channel.js';
@ -46,16 +45,11 @@ class HashtagChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return; if (this.isNoteMutedOrBlocked(note)) return;
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) { const clonedNote = await this.assignMyReaction(note);
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
note.renote.myReaction = myRenoteReaction;
}
}
this.connection.cacheNote(note); this.connection.cacheNote(clonedNote);
this.send('note', note); this.send('note', clonedNote);
} }
@bindThis @bindThis

View file

@ -48,7 +48,11 @@ class RoleTimelineChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return; if (this.isNoteMutedOrBlocked(note)) return;
this.send('note', note); const clonedNote = await this.assignMyReaction(note);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
} else { } else {
this.send(data.type, data.body); this.send(data.type, data.body);
} }

View file

@ -111,16 +111,11 @@ class UserListChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return; if (this.isNoteMutedOrBlocked(note)) return;
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) { const clonedNote = await this.assignMyReaction(note);
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
note.renote.myReaction = myRenoteReaction;
}
}
this.connection.cacheNote(note); this.connection.cacheNote(clonedNote);
this.send('note', note); this.send('note', clonedNote);
} }
@bindThis @bindThis