2018-03-05 01:27:15 +01:00
|
|
|
import { auth, basename } from './utils'
|
|
|
|
import { postWithTimeout } from '../_utils/ajax'
|
|
|
|
|
2018-03-05 02:16:33 +01:00
|
|
|
export async function postStatus (instanceName, accessToken, text, inReplyToId, mediaIds,
|
2018-03-05 01:27:15 +01:00
|
|
|
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 postWithTimeout(url, body, auth(accessToken))
|
2018-03-05 02:16:33 +01:00
|
|
|
}
|
2018-03-06 07:36:54 +01:00
|
|
|
|
|
|
|
export async function pinStatus (instanceName, accessToken, statusId) {
|
|
|
|
let url = `${basename(instanceName)}/api/v1/statuses/${statusId}/pin`
|
|
|
|
return postWithTimeout(url, null, auth(accessToken))
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function unpinStatus (instanceName, accessToken, statusId) {
|
|
|
|
let url = `${basename(instanceName)}/api/v1/statuses/${statusId}/unpin`
|
|
|
|
return postWithTimeout(url, null, auth(accessToken))
|
2018-03-06 08:56:48 +01:00
|
|
|
}
|