From c5f23bce7864bc1cffb82b54f62e019c4c04137d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Apr 2018 17:05:14 +0900 Subject: Implement like --- src/remote/activitypub/renderer/like.ts | 9 +++++++++ src/remote/activitypub/renderer/note.ts | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/remote/activitypub/renderer/like.ts (limited to 'src/remote/activitypub/renderer') diff --git a/src/remote/activitypub/renderer/like.ts b/src/remote/activitypub/renderer/like.ts new file mode 100644 index 0000000000..903b10789e --- /dev/null +++ b/src/remote/activitypub/renderer/like.ts @@ -0,0 +1,9 @@ +import config from '../../../config'; + +export default (user, post) => { + return { + type: 'Like', + actor: `${config.url}/@${user.username}`, + object: post.uri ? post.uri : `${config.url}/posts/${post._id}` + }; +}; diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts index b971a53951..bbab63db36 100644 --- a/src/remote/activitypub/renderer/note.ts +++ b/src/remote/activitypub/renderer/note.ts @@ -23,7 +23,7 @@ export default async (user: IUser, post: IPost) => { }); if (inReplyToUser !== null) { - inReplyTo = inReplyToPost.uri || `${config.url}/@${inReplyToUser.username}/${inReplyToPost._id}`; + inReplyTo = inReplyToPost.uri || `${config.url}/posts/${inReplyToPost._id}`; } } } else { @@ -33,7 +33,7 @@ export default async (user: IUser, post: IPost) => { const attributedTo = `${config.url}/@${user.username}`; return { - id: `${attributedTo}/${post._id}`, + id: `${config.url}/posts/${post._id}`, type: 'Note', attributedTo, content: post.textHtml, -- cgit v1.2.3-freya