summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann150 <johann.galle@protonmail.com>2022-06-10 07:31:58 +0200
committerGitHub <noreply@github.com>2022-06-10 14:31:58 +0900
commita683a7092dfe932ff7645ae08360124e5f0a232d (patch)
tree48b1e861d24cda63c92739cd23da740b4d75cae2
parentrefactor: follow button (#8789) (diff)
downloadsharkey-a683a7092dfe932ff7645ae08360124e5f0a232d.tar.gz
sharkey-a683a7092dfe932ff7645ae08360124e5f0a232d.tar.bz2
sharkey-a683a7092dfe932ff7645ae08360124e5f0a232d.zip
enhance(federation): use ActivityPub defined property in favour of proprietary property. (#8787)
* add activitypub `source` property * parse MFM from new `source` attribute
-rw-r--r--packages/backend/src/remote/activitypub/models/note.ts9
-rw-r--r--packages/backend/src/remote/activitypub/renderer/note.ts4
-rw-r--r--packages/backend/src/remote/activitypub/type.ts10
3 files changed, 20 insertions, 3 deletions
diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts
index ad24bbcd65..56c1a483ad 100644
--- a/packages/backend/src/remote/activitypub/models/note.ts
+++ b/packages/backend/src/remote/activitypub/models/note.ts
@@ -197,7 +197,14 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
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
if (reply && reply.hasPoll) {
diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts
index b7df0e9a39..df2ae65205 100644
--- a/packages/backend/src/remote/activitypub/renderer/note.ts
+++ b/packages/backend/src/remote/activitypub/renderer/note.ts
@@ -138,6 +138,10 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
summary,
content,
_misskey_content: text,
+ source: {
+ content: text,
+ mediaType: "text/x.misskeymarkdown",
+ },
_misskey_quote: quote,
quoteUrl: quote,
published: note.createdAt.toISOString(),
diff --git a/packages/backend/src/remote/activitypub/type.ts b/packages/backend/src/remote/activitypub/type.ts
index ef5b98b59e..5d00481b75 100644
--- a/packages/backend/src/remote/activitypub/type.ts
+++ b/packages/backend/src/remote/activitypub/type.ts
@@ -106,7 +106,10 @@ export const isPost = (object: IObject): object is IPost =>
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;
_misskey_talk: boolean;
@@ -114,7 +117,10 @@ export interface IPost extends IObject {
export interface IQuestion extends IObject {
type: 'Note' | 'Question';
- _misskey_content?: string;
+ source?: {
+ content: string;
+ mediaType: string;
+ };
_misskey_quote?: string;
quoteUrl?: string;
oneOf?: IQuestionChoice[];