Grab mutes from server on patched servers.

This commit is contained in:
Roger Braun 2017-02-20 18:01:45 +01:00
parent 3fd0d0d1cb
commit 9c1093b6ca
4 changed files with 45 additions and 3 deletions

View file

@ -16,6 +16,7 @@ const MENTIONS_URL = '/api/statuses/mentions.json'
const FRIENDS_URL = '/api/statuses/friends.json'
const FOLLOWING_URL = '/api/friendships/create.json'
const UNFOLLOWING_URL = '/api/friendships/destroy.json'
const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json'
// const USER_URL = '/api/users/show.json'
const oldfetch = window.fetch
@ -58,7 +59,7 @@ const fetchFriends = ({credentials}) => {
const fetchAllFollowing = ({username, credentials}) => {
const url = `${ALL_FOLLOWING_URL}/${username}.json`
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => data.json().users)
.then((data) => data.json())
}
const fetchMentions = ({username, sinceId = 0, credentials}) => {
@ -79,6 +80,22 @@ const fetchStatus = ({id, credentials}) => {
.then((data) => data.json())
}
const setUserMute = ({id, credentials, muted = true}) => {
const form = new FormData()
const muteInteger = muted ? 1 : 0
form.append('namespace', 'qvitter')
form.append('data', muteInteger)
form.append('topic', `mute:${id}`)
return fetch(QVITTER_USER_PREF_URL, {
method: 'POST',
headers: authHeaders(credentials),
body: form
})
}
const fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
const timelineUrls = {
public: PUBLIC_TIMELINE_URL,
@ -162,6 +179,14 @@ const uploadMedia = ({formData, credentials}) => {
.then((text) => (new DOMParser()).parseFromString(text, 'application/xml'))
}
const fetchMutes = ({credentials}) => {
const url = '/api/qvitter/mutes.json'
return fetch(url, {
headers: authHeaders(credentials)
}).then((data) => data.json())
}
const apiService = {
verifyCredentials,
fetchTimeline,
@ -177,7 +202,9 @@ const apiService = {
postStatus,
deleteStatus,
uploadMedia,
fetchAllFollowing
fetchAllFollowing,
setUserMute,
fetchMutes
}
export default apiService