switch to mastoapi
This commit is contained in:
parent
8702d23a13
commit
a64e744c1b
|
@ -118,14 +118,6 @@ export const mutations = {
|
|||
saveMuteIds (state, muteIds) {
|
||||
state.currentUser.muteIds = muteIds
|
||||
},
|
||||
muteUser (state, id) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'muted', true)
|
||||
},
|
||||
unmuteUser (state, id) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'muted', false)
|
||||
},
|
||||
setUserForStatus (state, status) {
|
||||
status.user = state.usersObject[status.user.id]
|
||||
},
|
||||
|
@ -218,11 +210,11 @@ const users = {
|
|||
},
|
||||
muteUser (store, id) {
|
||||
return store.rootState.api.backendInteractor.muteUser(id)
|
||||
.then(() => store.commit('muteUser', id))
|
||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
},
|
||||
unmuteUser (store, id) {
|
||||
return store.rootState.api.backendInteractor.unmuteUser(id)
|
||||
.then(() => store.commit('unmuteUser', id))
|
||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
},
|
||||
addFriends ({ rootState, commit }, fetchBy) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
@ -18,8 +18,6 @@ const MENTIONS_URL = '/api/statuses/mentions.json'
|
|||
const DM_TIMELINE_URL = '/api/statuses/dm_timeline.json'
|
||||
const FOLLOWERS_URL = '/api/statuses/followers.json'
|
||||
const FRIENDS_URL = '/api/statuses/friends.json'
|
||||
const MUTING_URL = '/api/v1/accounts/:id/mute'
|
||||
const UNMUTING_URL = '/api/v1/accounts/:id/unmute'
|
||||
const FOLLOWING_URL = '/api/friendships/create.json'
|
||||
const UNFOLLOWING_URL = '/api/friendships/destroy.json'
|
||||
const REGISTRATION_URL = '/api/account/register.json'
|
||||
|
@ -46,12 +44,13 @@ const MASTODON_USER_BLOCKS_URL = '/api/v1/blocks/'
|
|||
const MASTODON_USER_MUTES_URL = '/api/v1/mutes/'
|
||||
const MASTODON_BLOCK_USER_URL = id => `/api/v1/accounts/${id}/block`
|
||||
const MASTODON_UNBLOCK_USER_URL = id => `/api/v1/accounts/${id}/unblock`
|
||||
const MASTODON_MUTE_USER_URL = id => `/api/v1/accounts/${id}/mute`
|
||||
const MASTODON_UNMUTE_USER_URL = id => `/api/v1/accounts/${id}/unmute`
|
||||
|
||||
import { each, map } from 'lodash'
|
||||
import { parseStatus, parseUser, parseNotification } from '../entity_normalizer/entity_normalizer.service.js'
|
||||
import 'whatwg-fetch'
|
||||
import { StatusCodeError } from '../errors/errors'
|
||||
import { generateUrl } from '../../utils/url'
|
||||
|
||||
const oldfetch = window.fetch
|
||||
|
||||
|
@ -533,16 +532,14 @@ const fetchMutes = ({credentials}) => {
|
|||
}
|
||||
|
||||
const muteUser = ({id, credentials}) => {
|
||||
const url = generateUrl(MUTING_URL, { id })
|
||||
return promisedRequest(url, {
|
||||
return promisedRequest(MASTODON_MUTE_USER_URL(id), {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
|
||||
const unmuteUser = ({id, credentials}) => {
|
||||
const url = generateUrl(UNMUTING_URL, { id })
|
||||
return promisedRequest(url, {
|
||||
return promisedRequest(MASTODON_UNMUTE_USER_URL(id), {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
})
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
// Generate url based on template
|
||||
// Example: /api/v1/accounts/:id/mute -> /api/v1/accounts/123/mute
|
||||
export const generateUrl = (template, params = {}) => {
|
||||
let url = template
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
url = url.replace(':' + key, value)
|
||||
})
|
||||
return url
|
||||
}
|
Loading…
Reference in New Issue