expose Question

This commit is contained in:
mei23
2019-01-20 11:27:51 +09:00
parent 539cf811ec
commit f026c78e11
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import config from '../../../config';
import { ILocalUser } from '../../../models/user';
import { INote } from '../../../models/note';
export default async function renderQuestion(user: ILocalUser, note: INote) {
const question = {
type: 'Question',
id: `${config.url}/questions/${note._id}`,
actor: `${config.url}/users/${user._id}`,
content: note.text != null ? note.text : '',
oneOf: note.poll.choices.map(c => {
return {
name: c.text,
_misskey_votes: c.votes,
};
}),
};
return question;
}