expose Question
This commit is contained in:
parent
539cf811ec
commit
f026c78e11
2 changed files with 51 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ import Outbox, { packActivity } from './activitypub/outbox';
|
|||
import Followers from './activitypub/followers';
|
||||
import Following from './activitypub/following';
|
||||
import Featured from './activitypub/featured';
|
||||
import renderQuestion from '../remote/activitypub/renderer/question';
|
||||
|
||||
// Init router
|
||||
const router = new Router();
|
||||
|
|
@ -110,6 +111,36 @@ router.get('/notes/:note/activity', async ctx => {
|
|||
setResponseType(ctx);
|
||||
});
|
||||
|
||||
// question
|
||||
router.get('/questions/:question', async (ctx, next) => {
|
||||
if (!ObjectID.isValid(ctx.params.question)) {
|
||||
ctx.status = 404;
|
||||
return;
|
||||
}
|
||||
|
||||
const poll = await Note.findOne({
|
||||
_id: new ObjectID(ctx.params.question),
|
||||
visibility: { $in: ['public', 'home'] },
|
||||
localOnly: { $ne: true },
|
||||
poll: {
|
||||
$exists: true,
|
||||
$ne: null
|
||||
},
|
||||
});
|
||||
|
||||
if (poll === null) {
|
||||
ctx.status = 404;
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await User.findOne({
|
||||
_id: poll.userId
|
||||
});
|
||||
|
||||
ctx.body = pack(await renderQuestion(user as ILocalUser, poll));
|
||||
setResponseType(ctx);
|
||||
});
|
||||
|
||||
// outbox
|
||||
router.get('/users/:user/outbox', Outbox);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue