Merge branch 'feature/locked-accounts' into 'develop'

Feature/locked accounts

See merge request pleroma/pleroma-fe!274
This commit is contained in:
lambda 2018-06-12 16:57:18 +00:00
commit 6ea5cfe71e
14 changed files with 135 additions and 13 deletions

View file

@ -32,6 +32,9 @@ const USER_URL = '/api/users/show.json'
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const FOLLOW_REQUESTS_URL = '/api/pleroma/friend_requests'
const APPROVE_USER_URL = '/api/pleroma/friendships/approve'
const DENY_USER_URL = '/api/pleroma/friendships/deny'
import { each, map } from 'lodash'
import 'whatwg-fetch'
@ -127,11 +130,13 @@ const updateBanner = ({credentials, params}) => {
const updateProfile = ({credentials, params}) => {
let url = PROFILE_UPDATE_URL
console.log(params)
const form = new FormData()
each(params, (value, key) => {
if (key === 'description' || /* Always include description, because it might be empty */
value) {
/* Always include description and locked, because it might be empty or false */
if (key === 'description' || key === 'locked' || value) {
form.append(key, value)
}
})
@ -216,6 +221,22 @@ const unblockUser = ({id, credentials}) => {
}).then((data) => data.json())
}
const approveUser = ({id, credentials}) => {
let url = `${APPROVE_USER_URL}?user_id=${id}`
return fetch(url, {
headers: authHeaders(credentials),
method: 'POST'
}).then((data) => data.json())
}
const denyUser = ({id, credentials}) => {
let url = `${DENY_USER_URL}?user_id=${id}`
return fetch(url, {
headers: authHeaders(credentials),
method: 'POST'
}).then((data) => data.json())
}
const fetchUser = ({id, credentials}) => {
let url = `${USER_URL}?user_id=${id}`
return fetch(url, { headers: authHeaders(credentials) })
@ -240,6 +261,12 @@ const fetchAllFollowing = ({username, credentials}) => {
.then((data) => data.json())
}
const fetchFollowRequests = ({credentials}) => {
const url = FOLLOW_REQUESTS_URL
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => data.json())
}
const fetchConversation = ({id, credentials}) => {
let url = `${CONVERSATION_URL}/${id}.json?count=100`
return fetch(url, { headers: authHeaders(credentials) })
@ -442,7 +469,10 @@ const apiService = {
externalProfile,
followImport,
deleteAccount,
changePassword
changePassword,
fetchFollowRequests,
approveUser,
denyUser
}
export default apiService

View file

@ -42,6 +42,14 @@ const backendInteractorService = (credentials) => {
return apiService.unblockUser({credentials, id})
}
const approveUser = (id) => {
return apiService.approveUser({credentials, id})
}
const denyUser = (id) => {
return apiService.denyUser({credentials, id})
}
const startFetching = ({timeline, store, userId = false}) => {
return timelineFetcherService.startFetching({timeline, store, credentials, userId})
}
@ -51,6 +59,7 @@ const backendInteractorService = (credentials) => {
}
const fetchMutes = () => apiService.fetchMutes({credentials})
const fetchFollowRequests = () => apiService.fetchFollowRequests({credentials})
const register = (params) => apiService.register(params)
const updateAvatar = ({params}) => apiService.updateAvatar({credentials, params})
@ -87,7 +96,10 @@ const backendInteractorService = (credentials) => {
externalProfile,
followImport,
deleteAccount,
changePassword
changePassword,
fetchFollowRequests,
approveUser,
denyUser
}
return backendInteractorServiceInstance