diff options
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/api/api.service.js | 16 | ||||
| -rw-r--r-- | src/services/status_poster/status_poster.service.js | 15 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index c4d7fb53..067acbe9 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -645,8 +645,7 @@ const postStatus = ({ poll, mediaIds = [], inReplyToStatusId, - contentType, - mediaDescriptions + contentType }) => { const form = new FormData() const pollOptions = poll.options || [] @@ -673,7 +672,6 @@ const postStatus = ({ form.append('poll[options][]', option) }) } - form.append('descriptions', JSON.stringify(mediaDescriptions)) if (inReplyToStatusId) { form.append('in_reply_to_id', inReplyToStatusId) } @@ -712,6 +710,17 @@ const uploadMedia = ({ formData, credentials }) => { .then((data) => parseAttachment(data)) } +const setMediaDescription = ({ id, description, credentials }) => { + return promisedRequest({ + url: `${MASTODON_MEDIA_UPLOAD_URL}/${id}`, + method: 'PUT', + headers: authHeaders(credentials), + payload: { + description + } + }).then((data) => parseAttachment(data)) +} + const importBlocks = ({ file, credentials }) => { const formData = new FormData() formData.append('list', file) @@ -1181,6 +1190,7 @@ const apiService = { postStatus, deleteStatus, uploadMedia, + setMediaDescription, fetchMutes, muteUser, unmuteUser, diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js index 090ff673..7f5f501c 100644 --- a/src/services/status_poster/status_poster.service.js +++ b/src/services/status_poster/status_poster.service.js @@ -1,7 +1,7 @@ import { map } from 'lodash' import apiService from '../api/api.service.js' -const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, media = [], inReplyToStatusId = undefined, contentType = 'text/plain', mediaDescriptions = {} }) => { +const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, media = [], inReplyToStatusId = undefined, contentType = 'text/plain' }) => { const mediaIds = map(media, 'id') return apiService.postStatus({ @@ -13,8 +13,8 @@ const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, m mediaIds, inReplyToStatusId, contentType, - poll, - mediaDescriptions }) + poll + }) .then((data) => { if (!data.error) { store.dispatch('addNewStatuses', { @@ -39,9 +39,16 @@ const uploadMedia = ({ store, formData }) => { return apiService.uploadMedia({ credentials, formData }) } +const setMediaDescription = ({ store, id, description }) => { + const credentials = store.state.users.currentUser.credentials + + return apiService.setMediaDescription({ credentials, id, description }) +} + const statusPosterService = { postStatus, - uploadMedia + uploadMedia, + setMediaDescription } export default statusPosterService |
