Merge branch 'feat/idempotency' into 'develop'

Status posting Idempotency

See merge request pleroma/pleroma-fe!1194
This commit is contained in:
lain 2020-07-23 13:17:44 +00:00
commit 0ea23a03ce
4 changed files with 56 additions and 34 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()

View file

@ -11,7 +11,8 @@ const postStatus = ({
media = [],
inReplyToStatusId = undefined,
contentType = 'text/plain',
preview = false
preview = false,
idempotencyKey = ''
}) => {
const mediaIds = map(media, 'id')
@ -25,7 +26,8 @@ const postStatus = ({
inReplyToStatusId,
contentType,
poll,
preview
preview,
idempotencyKey
})
.then((data) => {
if (!data.error && !preview) {