attempt at html and note instead of article and markdown

This commit is contained in:
Moon Man 2023-12-31 12:21:29 -05:00
parent be53008a8c
commit c380a178f0
1 changed files with 23 additions and 8 deletions

View File

@ -1,4 +1,5 @@
import { readFileSync } from "node:fs";
import markdownit from "markdown-it";
import { Article } from "./article.js";
import { User, getByActor } from "./user.js";
import { fillRoute } from "./router.js";
@ -13,6 +14,8 @@ export const CONTEXT = "https://www.w3.org/ns/activitystreams";
export const PUBLIC = CONTEXT + "#Public";
export const TYPE = "application/activity+json";
const md = markdownit();
export const handleInboxPost = async (req: Request, res: Response) => {
try {
if (!req.body) {
@ -34,9 +37,13 @@ export const handleInboxPost = async (req: Request, res: Response) => {
return;
}
console.log("inbox POST:", req.url, req.body);
console.log("inbox POST:", activity.type);
if (activity.type === "Follow") {
if (activity.type === "Delete") {
res.status(202).end();
return;
}
else if (activity.type === "Follow") {
console.log(JSON.stringify(activity, null, 4));
const actor = await getByActor(activity.object);
@ -151,13 +158,17 @@ export const createArticleActivity = (article: Article, user: User) => {
id: objectId,
actor,
attributedTo: actor,
type: "Article",
type: "Note",
context,
content,
content: md.render(content),
to: [PUBLIC],
cc: [followers],
url: canonicalUrl,
mediaType: "text/html",
source: {
mediaType: "text/markdown",
content
},
published
};
@ -177,13 +188,17 @@ export const createArticleObject = (article: Article, nickname: string) => {
id: objectId,
actor,
attributedTo: actor,
type: "Article",
type: "Note",
context,
content,
content: md.render(content),
to: [PUBLIC],
cc: [followers],
url: canonicalUrl,
mediaType: "text/html",
source: {
mediaType: "text/markdown",
content
},
published
}