pinafore/routes/_api/statuses.js
Nolan Lawson 5f4e869eeb
add more fine-grained request timeouts (#387)
* add more fine-grained request timeouts

fixes #381

* tweak timeout
2018-06-13 07:38:36 -07:00

26 lines
694 B
JavaScript

import { auth, basename } from './utils'
import { post, WRITE_TIMEOUT } from '../_utils/ajax'
export async function postStatus (instanceName, accessToken, text, inReplyToId, mediaIds,
sensitive, spoilerText, visibility) {
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})
}