mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-03-24 04:53:33 +00:00
expose Question
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user