From d8911be6eabbec6cb78df5d7f4ea2cab1db8056e Mon Sep 17 00:00:00 2001 From: Moon Man Date: Mon, 1 Jan 2024 08:10:45 -0500 Subject: [PATCH] rm redundant check, use object build function --- src/activity.ts | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/activity.ts b/src/activity.ts index 3697445..8a7ab62 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -177,8 +177,7 @@ export const deleteArticleActivity = (article: Article, user: User) => { export const createArticleActivity = (article: Article, user: User) => { const actor = fillRoute("actor", user.nickname); - const published = typeof article.created_at === "number" ? new Date(article.created_at) : article.created_at; - const canonicalUrl = `https://${process.env.blog_host}/${article.slug}.html`; + const published = article.created_at; const context = fillRoute("context", article.id); const followers = fillRoute("followers", user.nickname); const activity: Record = { @@ -192,29 +191,7 @@ export const createArticleActivity = (article: Article, user: User) => { published }; - const objectId = fillRoute("object", article.id); - const content = readFileSync(article.file as string, "utf-8") + ` - -[Read on site](${canonicalUrl}) - `; - - activity.object = { - id: objectId, - actor, - attributedTo: actor, - type: "Note", - context, - content: md.render(content), - to: [PUBLIC], - cc: [followers], - url: canonicalUrl, - mediaType: "text/html", - source: { - mediaType: "text/markdown", - content - }, - published - }; + activity.object = createArticleObject(article, user.nickname); return activity; }; @@ -230,7 +207,7 @@ export const createArticleObject = (article: Article, nickname: string) => { [Read on site](${canonicalUrl}) `; - const published = typeof article.created_at === "number" ? new Date(article.created_at) : article.created_at; + const published = article.created_at; const followers = fillRoute("followers", nickname);