diff options
| author | Roger Braun <roger@rogerbraun.net> | 2016-10-30 16:53:58 +0100 |
|---|---|---|
| committer | Roger Braun <roger@rogerbraun.net> | 2016-10-30 16:54:44 +0100 |
| commit | 79805584613bd3d3ec5fba6481fc1ba02986a1a8 (patch) | |
| tree | 0003f122539fc8892e2175225bb52fbd028295e3 /src/services/api/api.service.js | |
| parent | 8630f91a13e8b8f7b56d2cb3dd2b700ad5ebd6f6 (diff) | |
Basic status posting.
Diffstat (limited to 'src/services/api/api.service.js')
| -rw-r--r-- | src/services/api/api.service.js | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 5a46451b..df7b4190 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -5,8 +5,8 @@ const PUBLIC_TIMELINE_URL = '/api/statuses/public_timeline.json' const PUBLIC_AND_EXTERNAL_TIMELINE_URL = '/api/statuses/public_and_external_timeline.json' const FAVORITE_URL = '/api/favorites/create' const UNFAVORITE_URL = '/api/favorites/destroy' +const STATUS_UPDATE_URL = '/api/statuses/update.json' // const CONVERSATION_URL = '/api/statusnet/conversation/'; -// const STATUS_UPDATE_URL = '/api/statuses/update.json'; // const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'; // const FORM_CONTENT_TYPE = {'Content-Type': 'application/x-www-form-urlencoded'}; @@ -57,11 +57,30 @@ const unfavorite = ({ id, credentials }) => { }) } +const postStatus = ({credentials, status, mediaIds, inReplyToStatusId}) => { + const idsText = mediaIds.join(',') + const form = new FormData() + + form.append('status', status) + form.append('source', 'Pleroma FE') + form.append('media_ids', idsText) + if (inReplyToStatusId) { + form.append('in_reply_to_status_id', inReplyToStatusId) + } + + return fetch(STATUS_UPDATE_URL, { + body: form, + method: 'POST', + headers: authHeaders(credentials) + }) +} + const apiService = { verifyCredentials, fetchTimeline, favorite, - unfavorite + unfavorite, + postStatus } export default apiService @@ -102,24 +121,6 @@ export default apiService // return $http.post(LOGIN_URL, null, { headers: authHeaders }); // }; -// const postStatus = ({status, mediaIds, in_reply_to_status_id}) => { -// const idsText = mediaIds.join(','); -// const form = new FormData(); - -// form.append('status', status); -// form.append('source', 'The Wired FE'); -// form.append('media_ids', idsText); -// if(in_reply_to_status_id) { -// form.append('in_reply_to_status_id', in_reply_to_status_id); -// }; - -// return fetch(STATUS_UPDATE_URL, { -// body: form, -// method: 'POST', -// headers: authHeaders -// }); -// }; - // const unfavorite = (id) => $http.post(`${UNFAVORITE_URL}/${id}.json`, null, {headers: authHeaders}); // // This was impossible to get to work with $http. You're supposed to set Content-Type |
