Merge branch 'io' into merge-upstream
This commit is contained in:
commit
2f437e3924
11 changed files with 171 additions and 24 deletions
|
@ -17,6 +17,7 @@ import type { MiNoteReaction } from '@/models/NoteReaction.js';
|
|||
import type { UsersRepository, NotesRepository, FollowingsRepository, PollsRepository, PollVotesRepository, NoteReactionsRepository, ChannelsRepository } from '@/models/_.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { isNotNull } from '@/misc/is-not-null.js';
|
||||
import { DebounceLoader } from '@/misc/loader.js';
|
||||
import type { OnModuleInit } from '@nestjs/common';
|
||||
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
||||
import type { ReactionService } from '../ReactionService.js';
|
||||
|
@ -29,6 +30,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||
private driveFileEntityService: DriveFileEntityService;
|
||||
private customEmojiService: CustomEmojiService;
|
||||
private reactionService: ReactionService;
|
||||
private noteLoader = new DebounceLoader(this.findNoteOrFail);
|
||||
|
||||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
|
@ -289,7 +291,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||
}, options);
|
||||
|
||||
const meId = me ? me.id : null;
|
||||
const note = typeof src === 'object' ? src : await this.notesRepository.findOneOrFail({ where: { id: src }, relations: ['user'] });
|
||||
const note = typeof src === 'object' ? src : await this.noteLoader.load(src);
|
||||
const host = note.userHost;
|
||||
|
||||
let text = note.text;
|
||||
|
@ -307,6 +309,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||
const reactionEmojiNames = Object.keys(note.reactions)
|
||||
.filter(x => x.startsWith(':') && x.includes('@') && !x.includes('@.')) // リモートカスタム絵文字のみ
|
||||
.map(x => this.reactionService.decodeReaction(x).reaction.replaceAll(':', ''));
|
||||
await this.customEmojiService.prefetchEmojis(this.aggregateNoteEmojis([note]));
|
||||
const packedFiles = options?._hint_?.packedFiles;
|
||||
|
||||
const packed: Packed<'Note'> = await awaitAll({
|
||||
|
@ -472,4 +475,12 @@ export class NoteEntityService implements OnModuleInit {
|
|||
|
||||
return await query.getCount();
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private async findNoteOrFail(id: string): Promise<MiNote> {
|
||||
return await this.notesRepository.findOneOrFail({
|
||||
where: { id },
|
||||
relations: ["user"],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue