Merge branch 'feat/language-content-map' into 'develop'
Add contentMap to outgoing posts via language detection Co-authored-by: Essem <smswessem@gmail.com> See merge request firefish/firefish!10601
This commit is contained in:
commit
f1341204d4
2 changed files with 8 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { In, IsNull } from "typeorm";
|
import { In, IsNull } from "typeorm";
|
||||||
|
import { detect as detectLanguage } from "tinyld";
|
||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js";
|
import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js";
|
||||||
import type { DriveFile } from "@/models/entities/drive-file.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 emojis = await getEmojis(note.emojis);
|
||||||
const apemojis = emojis.map((emoji) => renderEmoji(emoji));
|
const apemojis = emojis.map((emoji) => renderEmoji(emoji));
|
||||||
|
|
||||||
|
@ -152,6 +158,7 @@ export default async function renderNote(
|
||||||
attributedTo,
|
attributedTo,
|
||||||
summary,
|
summary,
|
||||||
content,
|
content,
|
||||||
|
contentMap,
|
||||||
source: {
|
source: {
|
||||||
content: text,
|
content: text,
|
||||||
mediaType: "text/x.misskeymarkdown",
|
mediaType: "text/x.misskeymarkdown",
|
||||||
|
|
|
@ -14,6 +14,7 @@ export interface IObject {
|
||||||
inReplyTo?: any;
|
inReplyTo?: any;
|
||||||
replies?: ICollection;
|
replies?: ICollection;
|
||||||
content?: string;
|
content?: string;
|
||||||
|
contentMap?: obj;
|
||||||
name?: string;
|
name?: string;
|
||||||
startTime?: Date;
|
startTime?: Date;
|
||||||
endTime?: Date;
|
endTime?: Date;
|
||||||
|
|
Loading…
Reference in a new issue