fix(wip): update custom emojis event

This commit is contained in:
Nya Candy 2024-07-30 23:44:02 +08:00 committed by fly_mc
parent 41be76fc53
commit 21e1598584
2 changed files with 6 additions and 4 deletions

View file

@ -121,8 +121,8 @@ export interface NoteEventTypes {
cw: string | null; cw: string | null;
text: string; text: string;
updatedAt: string; updatedAt: string;
tags: string[]; tags?: string[];
emojis: string[]; emojis?: Record<string, string>;
}; };
reacted: { reacted: {
reaction: string; reaction: string;

View file

@ -31,6 +31,7 @@ import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
import { extractHashtags } from "@/misc/extract-hashtags.js"; import { extractHashtags } from "@/misc/extract-hashtags.js";
import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js";
import { UtilityService } from "@/core/UtilityService.js"; import { UtilityService } from "@/core/UtilityService.js";
import { CustomEmojiService } from "@/core/CustomEmojiService.js";
type Option = Pick<MiNote, 'text' | 'cw' | 'updatedAt'> & { type Option = Pick<MiNote, 'text' | 'cw' | 'updatedAt'> & {
apHashtags?: string[] | null; apHashtags?: string[] | null;
@ -52,6 +53,7 @@ export class NoteUpdateService {
@Inject(DI.instancesRepository) @Inject(DI.instancesRepository)
private instancesRepository: InstancesRepository, private instancesRepository: InstancesRepository,
private customEmojiService: CustomEmojiService,
private userEntityService: UserEntityService, private userEntityService: UserEntityService,
private noteEntityService: NoteEntityService, private noteEntityService: NoteEntityService,
private globalEventService: GlobalEventService, private globalEventService: GlobalEventService,
@ -128,8 +130,8 @@ export class NoteUpdateService {
cw: ps.cw, cw: ps.cw,
text: ps.text ?? '', // prevent null text: ps.text ?? '', // prevent null
updatedAt: ps.updatedAt.toISOString(), updatedAt: ps.updatedAt.toISOString(),
tags, tags: tags.length > 0 ? tags : undefined,
emojis, emojis: note.userHost != null ? await this.customEmojiService.populateEmojis(emojis, note.userHost) : undefined,
}); });
if (this.userEntityService.isLocalUser(user) && !note.localOnly) { if (this.userEntityService.isLocalUser(user) && !note.localOnly) {