#436 - merge develop
This commit is contained in:
commit
d3218807b4
22 changed files with 1759 additions and 13 deletions
|
@ -15,6 +15,10 @@ 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'
|
||||
const TAG_USER_URL = '/api/pleroma/admin/users/tag'
|
||||
const PERMISSION_GROUP_URL = '/api/pleroma/admin/permission_group'
|
||||
const ACTIVATION_STATUS_URL = '/api/pleroma/admin/activation_status'
|
||||
const ADMIN_USER_URL = '/api/pleroma/admin/user'
|
||||
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
||||
|
||||
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
|
||||
|
@ -352,6 +356,86 @@ const fetchStatus = ({id, credentials}) => {
|
|||
.then((data) => parseStatus(data))
|
||||
}
|
||||
|
||||
const tagUser = ({tag, credentials, ...options}) => {
|
||||
const screenName = options.screen_name
|
||||
const form = {
|
||||
nicknames: [screenName],
|
||||
tags: [tag]
|
||||
}
|
||||
|
||||
const headers = authHeaders(credentials)
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
return fetch(TAG_USER_URL, {
|
||||
method: 'PUT',
|
||||
headers: headers,
|
||||
body: JSON.stringify(form)
|
||||
})
|
||||
}
|
||||
|
||||
const untagUser = ({tag, credentials, ...options}) => {
|
||||
const screenName = options.screen_name
|
||||
const body = {
|
||||
nicknames: [screenName],
|
||||
tags: [tag]
|
||||
}
|
||||
|
||||
const headers = authHeaders(credentials)
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
return fetch(TAG_USER_URL, {
|
||||
method: 'DELETE',
|
||||
headers: headers,
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
|
||||
const addRight = ({right, credentials, ...user}) => {
|
||||
const screenName = user.screen_name
|
||||
|
||||
return fetch(`${PERMISSION_GROUP_URL}/${screenName}/${right}`, {
|
||||
method: 'POST',
|
||||
headers: authHeaders(credentials),
|
||||
body: {}
|
||||
})
|
||||
}
|
||||
|
||||
const deleteRight = ({right, credentials, ...user}) => {
|
||||
const screenName = user.screen_name
|
||||
|
||||
return fetch(`${PERMISSION_GROUP_URL}/${screenName}/${right}`, {
|
||||
method: 'DELETE',
|
||||
headers: authHeaders(credentials),
|
||||
body: {}
|
||||
})
|
||||
}
|
||||
|
||||
const setActivationStatus = ({status, credentials, ...user}) => {
|
||||
const screenName = user.screen_name
|
||||
const body = {
|
||||
status: status
|
||||
}
|
||||
|
||||
const headers = authHeaders(credentials)
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
return fetch(`${ACTIVATION_STATUS_URL}/${screenName}.json`, {
|
||||
method: 'PUT',
|
||||
headers: headers,
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
|
||||
const deleteUser = ({credentials, ...user}) => {
|
||||
const screenName = user.screen_name
|
||||
const headers = authHeaders(credentials)
|
||||
|
||||
return fetch(`${ADMIN_USER_URL}.json?nickname=${screenName}`, {
|
||||
method: 'DELETE',
|
||||
headers: headers
|
||||
})
|
||||
}
|
||||
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false, userId = false, tag = false, withMuted = false}) => {
|
||||
const timelineUrls = {
|
||||
public: MASTODON_PUBLIC_TIMELINE,
|
||||
|
@ -666,6 +750,12 @@ const apiService = {
|
|||
fetchBlocks,
|
||||
fetchOAuthTokens,
|
||||
revokeOAuthToken,
|
||||
tagUser,
|
||||
untagUser,
|
||||
deleteUser,
|
||||
addRight,
|
||||
deleteRight,
|
||||
setActivationStatus,
|
||||
register,
|
||||
getCaptcha,
|
||||
updateAvatar,
|
||||
|
|
|
@ -62,6 +62,30 @@ const backendInteractorService = (credentials) => {
|
|||
return timelineFetcherService.startFetching({timeline, store, credentials, userId, tag})
|
||||
}
|
||||
|
||||
const tagUser = ({screen_name}, tag) => {
|
||||
return apiService.tagUser({screen_name, tag, credentials})
|
||||
}
|
||||
|
||||
const untagUser = ({screen_name}, tag) => {
|
||||
return apiService.untagUser({screen_name, tag, credentials})
|
||||
}
|
||||
|
||||
const addRight = ({screen_name}, right) => {
|
||||
return apiService.addRight({screen_name, right, credentials})
|
||||
}
|
||||
|
||||
const deleteRight = ({screen_name}, right) => {
|
||||
return apiService.deleteRight({screen_name, right, credentials})
|
||||
}
|
||||
|
||||
const setActivationStatus = ({screen_name}, status) => {
|
||||
return apiService.setActivationStatus({screen_name, status, credentials})
|
||||
}
|
||||
|
||||
const deleteUser = ({screen_name}) => {
|
||||
return apiService.deleteUser({screen_name, credentials})
|
||||
}
|
||||
|
||||
const fetchMutes = () => apiService.fetchMutes({credentials})
|
||||
const muteUser = (id) => apiService.muteUser({credentials, id})
|
||||
const unmuteUser = (id) => apiService.unmuteUser({credentials, id})
|
||||
|
@ -104,6 +128,12 @@ const backendInteractorService = (credentials) => {
|
|||
fetchBlocks,
|
||||
fetchOAuthTokens,
|
||||
revokeOAuthToken,
|
||||
tagUser,
|
||||
untagUser,
|
||||
addRight,
|
||||
deleteRight,
|
||||
deleteUser,
|
||||
setActivationStatus,
|
||||
register,
|
||||
getCaptcha,
|
||||
updateAvatar,
|
||||
|
|
|
@ -67,6 +67,11 @@ export const parseUser = (data) => {
|
|||
output.statusnet_blocking = relationship.blocking
|
||||
output.muted = relationship.muting
|
||||
}
|
||||
|
||||
output.rights = {
|
||||
moderator: data.pleroma.is_moderator,
|
||||
admin: data.pleroma.is_admin
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: handle is_local
|
||||
|
@ -103,7 +108,12 @@ export const parseUser = (data) => {
|
|||
|
||||
// QVITTER ONLY FOR NOW
|
||||
// Really only applies to logged in user, really.. I THINK
|
||||
output.rights = data.rights
|
||||
if (data.rights) {
|
||||
output.rights = {
|
||||
moderator: data.rights.delete_others_notice,
|
||||
admin: data.rights.admin
|
||||
}
|
||||
}
|
||||
output.no_rich_text = data.no_rich_text
|
||||
output.default_scope = data.default_scope
|
||||
output.hide_follows = data.hide_follows
|
||||
|
@ -125,6 +135,13 @@ export const parseUser = (data) => {
|
|||
output.follow_request_count = data.pleroma.follow_request_count
|
||||
}
|
||||
|
||||
if (data.pleroma) {
|
||||
output.tags = data.pleroma.tags
|
||||
output.deactivated = data.pleroma.deactivated
|
||||
}
|
||||
|
||||
output.tags = output.tags || []
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue