diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-05-15 18:26:09 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-05-15 18:26:09 +0000 |
| commit | fedcc716762339b72f6a99722f2c54a300fdff4f (patch) | |
| tree | 15c89025e846ba322003bc9cb0965d3ed1fac00a /src/services/api/api.service.js | |
| parent | 9eac355851b40aa5df9e6b23eca8c0ff1698e670 (diff) | |
| parent | 2ce01863273fdefad7bca945f5d58d50a0e8d77b (diff) | |
Merge branch '468-pin-status' into 'develop'
Add ability to pin posts
Closes #468
See merge request pleroma/pleroma-fe!770
Diffstat (limited to 'src/services/api/api.service.js')
| -rw-r--r-- | src/services/api/api.service.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index b7a602b8..5f40cfa6 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -51,6 +51,8 @@ const MASTODON_STATUS_FAVORITEDBY_URL = id => `/api/v1/statuses/${id}/favourited const MASTODON_STATUS_REBLOGGEDBY_URL = id => `/api/v1/statuses/${id}/reblogged_by` const MASTODON_PROFILE_UPDATE_URL = '/api/v1/accounts/update_credentials' const MASTODON_REPORT_USER_URL = '/api/v1/reports' +const MASTODON_PIN_OWN_STATUS = id => `/api/v1/statuses/${id}/pin` +const MASTODON_UNPIN_OWN_STATUS = id => `/api/v1/statuses/${id}/unpin` import { each, map, concat, last } from 'lodash' import { parseStatus, parseUser, parseNotification, parseAttachment } from '../entity_normalizer/entity_normalizer.service.js' @@ -210,6 +212,16 @@ const unfollowUser = ({id, credentials}) => { }).then((data) => data.json()) } +const pinOwnStatus = ({ id, credentials }) => { + return promisedRequest({ url: MASTODON_PIN_OWN_STATUS(id), credentials, method: 'POST' }) + .then((data) => parseStatus(data)) +} + +const unpinOwnStatus = ({ id, credentials }) => { + return promisedRequest({ url: MASTODON_UNPIN_OWN_STATUS(id), credentials, method: 'POST' }) + .then((data) => parseStatus(data)) +} + const blockUser = ({id, credentials}) => { return fetch(MASTODON_BLOCK_USER_URL(id), { headers: authHeaders(credentials), @@ -488,6 +500,12 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use .then((data) => data.map(isNotifications ? parseNotification : parseStatus)) } +const fetchPinnedStatuses = ({ id, credentials }) => { + const url = MASTODON_USER_TIMELINE_URL(id) + '?pinned=true' + return promisedRequest({ url, credentials }) + .then((data) => data.map(parseStatus)) +} + const verifyCredentials = (user) => { return fetch(LOGIN_URL, { method: 'POST', @@ -708,6 +726,7 @@ const reportUser = ({credentials, userId, statusIds, comment, forward}) => { const apiService = { verifyCredentials, fetchTimeline, + fetchPinnedStatuses, fetchConversation, fetchStatus, fetchFriends, @@ -715,6 +734,8 @@ const apiService = { fetchFollowers, followUser, unfollowUser, + pinOwnStatus, + unpinOwnStatus, blockUser, unblockUser, fetchUser, |
