Compare commits
No commits in common. "d8911be6eabbec6cb78df5d7f4ea2cab1db8056e" and "5e298ce255b7e8c19bd8496c46c34f90d7c88a23" have entirely different histories.
d8911be6ea
...
5e298ce255
|
@ -161,7 +161,7 @@ export const deleteArticleActivity = (article: Article, user: User) => {
|
||||||
const canonicalUrl = `https://${process.env.blog_host}/${article.slug}.html`;
|
const canonicalUrl = `https://${process.env.blog_host}/${article.slug}.html`;
|
||||||
|
|
||||||
const activity: Record<string, any> = {
|
const activity: Record<string, any> = {
|
||||||
id: fillRoute("activity", article.id) + "/delete",
|
id: fillRoute("activity", article.id + 1_000_000_000),
|
||||||
"@context": CONTEXT,
|
"@context": CONTEXT,
|
||||||
summary: `${user.nickname} deleted article ${canonicalUrl}`,
|
summary: `${user.nickname} deleted article ${canonicalUrl}`,
|
||||||
type: "Delete",
|
type: "Delete",
|
||||||
|
@ -177,7 +177,8 @@ export const deleteArticleActivity = (article: Article, user: User) => {
|
||||||
|
|
||||||
export const createArticleActivity = (article: Article, user: User) => {
|
export const createArticleActivity = (article: Article, user: User) => {
|
||||||
const actor = fillRoute("actor", user.nickname);
|
const actor = fillRoute("actor", user.nickname);
|
||||||
const published = article.created_at;
|
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 context = fillRoute("context", article.id);
|
const context = fillRoute("context", article.id);
|
||||||
const followers = fillRoute("followers", user.nickname);
|
const followers = fillRoute("followers", user.nickname);
|
||||||
const activity: Record<string, any> = {
|
const activity: Record<string, any> = {
|
||||||
|
@ -191,7 +192,29 @@ export const createArticleActivity = (article: Article, user: User) => {
|
||||||
published
|
published
|
||||||
};
|
};
|
||||||
|
|
||||||
activity.object = createArticleObject(article, user.nickname);
|
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
|
||||||
|
};
|
||||||
|
|
||||||
return activity;
|
return activity;
|
||||||
};
|
};
|
||||||
|
@ -207,7 +230,7 @@ export const createArticleObject = (article: Article, nickname: string) => {
|
||||||
[Read on site](${canonicalUrl})
|
[Read on site](${canonicalUrl})
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const published = article.created_at;
|
const published = typeof article.created_at === "number" ? new Date(article.created_at) : article.created_at;
|
||||||
|
|
||||||
const followers = fillRoute("followers", nickname);
|
const followers = fillRoute("followers", nickname);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue