Skip to content
Snippets Groups Projects
Commit f8ebbfac authored by syuilo's avatar syuilo
Browse files

Revert "Fix"

This reverts commit 8afdb5ae.
parent 8afdb5ae
No related branches found
No related tags found
No related merge requests found
import * as express from 'express';
import context from '../../remote/activitypub/renderer/context';
import render from '../../remote/activitypub/renderer/note';
import parseAcct from '../../acct/parse';
import Post from '../../models/post';
import User from '../../models/user';
const app = express();
app.disable('x-powered-by');
app.get('/posts/:post', async (req, res, next) => {
app.get('/@:user/:post', async (req, res, next) => {
const accepted = req.accepts(['html', 'application/activity+json', 'application/ld+json']);
if (!(['application/activity+json', 'application/ld+json'] as any[]).includes(accepted)) {
return next();
}
const post = await Post.findOne({
_id: req.params.post
});
if (post === null) {
return res.sendStatus(404);
const { username, host } = parseAcct(req.params.user);
if (host !== null) {
return res.sendStatus(422);
}
const user = await User.findOne({
_id: post.userId
usernameLower: username.toLowerCase(),
host: null
});
if (user === null) {
return res.sendStatus(404);
}
const post = await Post.findOne({
_id: req.params.post,
userId: user._id
});
if (post === null) {
return res.sendStatus(404);
}
const rendered = await render(user, post);
rendered['@context'] = context;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment