Add contentMap to outgoing posts via language detection

This commit is contained in:
Essem 2023-09-21 21:13:09 +00:00 committed by Kainoa Kanter
parent 88972fe12f
commit bac39db74b
2 changed files with 8 additions and 0 deletions

View file

@ -1,4 +1,5 @@
import { In, IsNull } from "typeorm";
import { detect as detectLanguage } from "tinyld";
import config from "@/config/index.js";
import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js";
import type { DriveFile } from "@/models/entities/drive-file.js";
@ -114,6 +115,11 @@ export default async function renderNote(
}),
);
const lang = detectLanguage(text);
const contentMap = lang ? {
[lang]: content
} : null;
const emojis = await getEmojis(note.emojis);
const apemojis = emojis.map((emoji) => renderEmoji(emoji));
@ -152,6 +158,7 @@ export default async function renderNote(
attributedTo,
summary,
content,
contentMap,
source: {
content: text,
mediaType: "text/x.misskeymarkdown",

View file

@ -14,6 +14,7 @@ export interface IObject {
inReplyTo?: any;
replies?: ICollection;
content?: string;
contentMap?: obj;
name?: string;
startTime?: Date;
endTime?: Date;