enhance(federation): use ActivityPub defined property in favour of proprietary property. (#8787)

* add activitypub `source` property

* parse MFM from new `source` attribute
This commit is contained in:
Johann150 2022-06-10 07:31:58 +02:00 committed by GitHub
parent 42f48ffea2
commit a683a7092d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View File

@ -197,7 +197,14 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
const cw = note.summary === '' ? null : note.summary; const cw = note.summary === '' ? null : note.summary;
// テキストのパース // テキストのパース
const text = typeof note._misskey_content !== 'undefined' ? note._misskey_content : (note.content ? htmlToMfm(note.content, note.tag) : null); let text: string | null = null;
if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source?.content === 'string') {
text = note.source.content;
} else if (typeof note._misskey_content === 'string') {
text = note._misskey_content;
} else if (typeof note.content === 'string') {
text = htmlToMfm(note.content, note.tag);
}
// vote // vote
if (reply && reply.hasPoll) { if (reply && reply.hasPoll) {

View File

@ -138,6 +138,10 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
summary, summary,
content, content,
_misskey_content: text, _misskey_content: text,
source: {
content: text,
mediaType: "text/x.misskeymarkdown",
},
_misskey_quote: quote, _misskey_quote: quote,
quoteUrl: quote, quoteUrl: quote,
published: note.createdAt.toISOString(), published: note.createdAt.toISOString(),

View File

@ -106,7 +106,10 @@ export const isPost = (object: IObject): object is IPost =>
export interface IPost extends IObject { export interface IPost extends IObject {
type: 'Note' | 'Question' | 'Article' | 'Audio' | 'Document' | 'Image' | 'Page' | 'Video' | 'Event'; type: 'Note' | 'Question' | 'Article' | 'Audio' | 'Document' | 'Image' | 'Page' | 'Video' | 'Event';
_misskey_content?: string; source?: {
content: string;
mediaType: string;
};
_misskey_quote?: string; _misskey_quote?: string;
quoteUrl?: string; quoteUrl?: string;
_misskey_talk: boolean; _misskey_talk: boolean;
@ -114,7 +117,10 @@ export interface IPost extends IObject {
export interface IQuestion extends IObject { export interface IQuestion extends IObject {
type: 'Note' | 'Question'; type: 'Note' | 'Question';
_misskey_content?: string; source?: {
content: string;
mediaType: string;
};
_misskey_quote?: string; _misskey_quote?: string;
quoteUrl?: string; quoteUrl?: string;
oneOf?: IQuestionChoice[]; oneOf?: IQuestionChoice[];