Hey, lets retrieve posts.

This commit is contained in:
Andrew Pietila 2023-11-21 21:07:59 -06:00
parent a2d3a45095
commit c0e0ec1579
2 changed files with 17 additions and 0 deletions

View file

@ -143,6 +143,10 @@ module.exports = {
},
activity: new Proxy({}, {
get: (target, key) => {
return db.prepare("SELECT * FROM activity_objects WHERE uri_id = ?").get(key);
},
set: (target, key, value) => {
db.prepare("INSERT INTO activity_objects (object, type, local, uri_id, owner, created_at) VALUES (?, ?, ?, ?, ?, ?)").run(value.object, value.type, value.local.toString(), key, value.owner, value.created_at);
},

View file

@ -0,0 +1,13 @@
const databaseHandler = require("../../../../lib/database-handler");
module.exports = {
route: (routeObj) => {
routeObj.get((req, res) => {
res.header("content-type", "application/activity+json");
console.log(`Attempting object https://${req.header.host}/users/${req.params.username}/statuses/${req.params.statusId}`);
console.log(databaseHandler.activity[`https://${req.header.host}/users/${req.params.username}/statuses/${req.params.statusId}`]);
res.send(databaseHandler.activity[`https://${req.header.host}/users/${req.params.username}/statuses/${req.params.statusId}`].object);
res.end();
});
},
};