rm redundant check, use object build function
This commit is contained in:
parent
677e8c9b27
commit
d8911be6ea
|
@ -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<string, any> = {
|
||||
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue