add basic idempotency support

This commit is contained in:
Shpuld Shpuldson 2020-07-15 16:19:57 +03:00
parent 297a0c1f7f
commit 89a677f5e8
3 changed files with 52 additions and 28 deletions

View file

@ -631,7 +631,8 @@ const postStatus = ({
mediaIds = [],
inReplyToStatusId,
contentType,
preview
preview,
idempotencyKey
}) => {
const form = new FormData()
const pollOptions = poll.options || []
@ -665,10 +666,15 @@ const postStatus = ({
form.append('preview', 'true')
}
let postHeaders = authHeaders(credentials)
if (idempotencyKey) {
postHeaders['idempotency-key'] = idempotencyKey
}
return fetch(MASTODON_POST_STATUS_URL, {
body: form,
method: 'POST',
headers: authHeaders(credentials)
headers: postHeaders
})
.then((response) => {
return response.json()