Skip to content

Commit

Permalink
use ActivityPub defined property
Browse files Browse the repository at this point in the history
add activitypub `source` property
parse MFM from new `source` attribute
  • Loading branch information
atsu1125 committed Sep 28, 2023
1 parent b895645 commit 7ea9015
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/remote/activitypub/models/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ export async function createNote(value: string | IObject, resolver?: Resolver |
const cw = note.summary === '' ? null : note.summary;

// テキストのパース
const text = 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 !== 'undefined') {
text = note._misskey_content;
} else if (typeof note.content === 'string') {
text = htmlToMfm(note.content, note.tag);
}

// vote
if (reply && reply.poll) {
Expand Down
4 changes: 4 additions & 0 deletions src/remote/activitypub/renderer/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export default async function renderNote(note: INote, dive = true): Promise<any>
summary,
content,
_misskey_content: text,
source: {
content: text,
mediaType: "text/x.misskeymarkdown",
},
_misskey_quote: quote,
quoteUri: quote,
published: note.createdAt.toISOString(),
Expand Down
8 changes: 8 additions & 0 deletions src/remote/activitypub/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export interface IOrderedCollectionPage extends IObject {
export interface IPost extends IObject {
type: 'Note' | 'Question' | 'Article' | 'Audio' | 'Document' | 'Image' | 'Page' | 'Video' | 'Event';
_misskey_content?: string;
source?: {
content: string;
mediaType: string;
};
_misskey_quote?: string;
quoteUrl?: string;
quoteUri?: string;
Expand All @@ -159,6 +163,10 @@ export const isTombstone = (object: IObject): object is ITombstone =>
export interface IQuestion extends IObject {
type: 'Note' | 'Question';
_misskey_content?: string;
source?: {
content: string;
mediaType: string;
};
_misskey_quote?: string;
quoteUrl?: string;
quoteUri?: string;
Expand Down

0 comments on commit 7ea9015

Please sign in to comment.