forked from shadowfacts/shadowfacts.net
29 lines
774 B
TypeScript
29 lines
774 B
TypeScript
import { Router } from "express";
|
|
import { Database } from "sqlite3";
|
|
|
|
const domain = process.env.DOMAIN;
|
|
|
|
export default function conversation(router: Router) {
|
|
router.get("/ap/conversation/:id", (req, res) => {
|
|
const db = req.app.get("db") as Database;
|
|
db.all("SELECT * FROM notes WHERE conversation = $conversation", {
|
|
$conversation: `https://${domain}/ap/conversation/${req.params.id}`
|
|
}, (err, rows) => {
|
|
if (err) {
|
|
res.status(500).end(err);
|
|
} else {
|
|
const notes = rows.map(row => {
|
|
return {
|
|
id: row.id,
|
|
attributedTo: row.attributed_to,
|
|
content: row.content,
|
|
published: row.published,
|
|
inReplyTo: row.in_reply_to,
|
|
conversation: row.conversation
|
|
};
|
|
});
|
|
res.json(notes).end();
|
|
}
|
|
});
|
|
});
|
|
} |