[mastodon-client] fix posting polls

This commit is contained in:
Laura Hausmann 2023-07-09 22:59:04 +02:00
parent b4d52ee24c
commit 8d988e6456
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 20 additions and 1 deletions

View File

@ -67,6 +67,25 @@ export function apiStatusMastodon(router: Router): void {
const { sensitive } = body;
body.sensitive =
typeof sensitive === "string" ? sensitive === "true" : sensitive;
if (body.poll) {
if (
body.poll.expires_in != null &&
typeof body.poll.expires_in === "string"
)
body.poll.expires_in = parseInt(body.poll.expires_in);
if (
body.poll.multiple != null &&
typeof body.poll.multiple === "string"
)
body.poll.multiple = body.poll.multiple == "true";
if (
body.poll.hide_totals != null &&
typeof body.poll.hide_totals === "string"
)
body.poll.hide_totals = body.poll.hide_totals == "true";
}
const data = await client.postStatus(text, body);
ctx.body = convertStatus(data.data);
} catch (e: any) {

View File

@ -1169,7 +1169,7 @@ export default class Misskey implements MegalodonInterface {
let pollParam = {
choices: options.poll.options,
expiresAt: null,
expiredAfter: options.poll.expires_in
expiredAfter: options.poll.expires_in * 1000
}
if (options.poll.multiple !== undefined) {
pollParam = Object.assign(pollParam, {