pinafore/routes/_api/statuses.js

26 lines
694 B
JavaScript
Raw Normal View History

2018-03-05 00:27:15 +00:00
import { auth, basename } from './utils'
import { post, WRITE_TIMEOUT } from '../_utils/ajax'
2018-03-05 00:27:15 +00:00
2018-03-05 01:16:33 +00:00
export async function postStatus (instanceName, accessToken, text, inReplyToId, mediaIds,
2018-04-19 03:43:13 +00:00
sensitive, spoilerText, visibility) {
2018-03-05 00:27:15 +00:00
let url = `${basename(instanceName)}/api/v1/statuses`
let body = {
status: text,
in_reply_to_id: inReplyToId,
media_ids: mediaIds,
sensitive: sensitive,
spoiler_text: spoilerText,
visibility: visibility
}
for (let key of Object.keys(body)) {
let value = body[key]
if (!value || (Array.isArray(value) && !value.length)) {
delete body[key]
}
}
return post(url, body, auth(accessToken), {timeout: WRITE_TIMEOUT})
2018-03-05 01:16:33 +00:00
}