server/router/activitypub.js
Artem Anufrij cff48aaada
All checks were successful
continuous-integration/drone Build is passing
move
2023-02-08 12:30:56 +01:00

89 lines
2.1 KiB
JavaScript

const express = require("express");
const router = new express.Router();
const database = require("../services/database");
const server = require("../server");
const config = server.config;
router.route("/:user")
.get((req, res) => {
database.userByName(req.params.user.toLowerCase(), user => {
if (user == undefined) {
return req.status(404).end();
}
let id = "https://" + config.domain + "/users/" + user.name;
let inbox = "https://" + config.domain + "/users/" + user.name + "/inbox";
let outbox = "https://" + config.domain + "/users/" + user.name + "/outbox";
let followers = "https://" + config.domain + "/users/" + user.name + "/followers";
let following = "https://" + config.domain + "/users/" + user.name + "/followinig";
let liked = "https://" + config.domain + "/users/" + user.name + "/liked";
let response = {
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Person",
"id": id,
"name": "Artem",
"preferredUsername": user.name,
"summary": "cajon player and e-bass junkie",
"inbox": inbox,
"outbox": outbox,
"followers": followers,
"following": following,
"liked": liked
}
res.json(response).end();
});
});
router.route("/:user/inbox")
.get((req, res) => {
console.log(req);
res.end();
})
.post((req, res) => {
console.log(req);
res.end();
});
router.route("/:user/outbox")
.get((req, res) => {
})
.post((req, res) => {
console.log(req);
res.end();
});
router.route("/:user/followers")
.get((req, res) => {
console.log(req);
res.end();
})
.post((req, res) => {
console.log(req);
res.end();
});
router.route("/:user/following")
.get((req, res) => {
console.log(req);
res.end();
})
.post((req, res) => {
console.log(req);
res.end();
});
router.route("/:user/liked")
.get((req, res) => {
console.log(req);
res.end();
})
.post((req, res) => {
console.log(req);
res.end();
});
module.exports = router;