2019-02-23 21:40:26 +00:00
|
|
|
import request from '@/utils/request'
|
2019-03-22 20:58:58 +00:00
|
|
|
import { getToken } from '@/utils/auth'
|
2019-03-23 14:09:48 +00:00
|
|
|
import { baseName } from './utils'
|
2019-02-23 21:40:26 +00:00
|
|
|
|
2019-10-11 00:28:55 +00:00
|
|
|
export async function activateUsers(nicknames, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/activate`,
|
|
|
|
method: 'patch',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-10 23:49:16 +00:00
|
|
|
export async function addRight(nicknames, right, authHost, token) {
|
2019-02-23 21:40:26 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2019-10-10 23:49:16 +00:00
|
|
|
url: `/api/pleroma/admin/users/permission_group/${right}`,
|
2019-06-11 15:13:48 +00:00
|
|
|
method: 'post',
|
2019-10-10 23:49:16 +00:00
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
2019-02-23 21:40:26 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function approveUserAccount(nicknames, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: '/api/pleroma/admin/users/approve',
|
|
|
|
method: 'patch',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function confirmUserEmail(nicknames, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: '/api/pleroma/admin/users/confirm_email',
|
|
|
|
method: 'patch',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-11 15:13:48 +00:00
|
|
|
export async function createNewAccount(nickname, email, password, authHost, token) {
|
2019-02-26 19:50:25 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2019-06-11 15:13:48 +00:00
|
|
|
url: '/api/pleroma/admin/users',
|
|
|
|
method: 'post',
|
|
|
|
headers: authHeaders(token),
|
2019-09-23 19:00:28 +00:00
|
|
|
data: { users: [{ nickname, email, password }] }
|
2019-02-26 19:50:25 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-11 00:28:55 +00:00
|
|
|
export async function deactivateUsers(nicknames, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/deactivate`,
|
|
|
|
method: 'patch',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-10 23:49:16 +00:00
|
|
|
export async function deleteRight(nicknames, right, authHost, token) {
|
2019-03-01 17:32:03 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2019-10-10 23:49:16 +00:00
|
|
|
url: `/api/pleroma/admin/users/permission_group/${right}`,
|
2019-06-11 15:13:48 +00:00
|
|
|
method: 'delete',
|
2019-10-10 23:49:16 +00:00
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
2019-03-01 17:32:03 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-16 12:24:35 +00:00
|
|
|
export async function deleteUsers(nicknames, authHost, token) {
|
2019-03-22 21:18:57 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2019-10-16 12:24:35 +00:00
|
|
|
url: `/api/pleroma/admin/users`,
|
2019-06-11 15:13:48 +00:00
|
|
|
method: 'delete',
|
2019-10-16 12:24:35 +00:00
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
2019-03-22 21:18:57 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-07-01 20:48:04 +00:00
|
|
|
export async function disableMfa(nickname, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/disable_mfa`,
|
|
|
|
method: 'put',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nickname }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-07-24 20:50:45 +00:00
|
|
|
export async function fetchUser(id, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/${id}`,
|
|
|
|
method: 'get',
|
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function fetchUsers(filters, authHost, token, page = 1) {
|
2020-02-17 01:02:50 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
|
2020-02-17 01:02:50 +00:00
|
|
|
method: 'get',
|
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function fetchUserCredentials(nickname, authHost, token) {
|
2020-02-17 01:02:50 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/${nickname}/credentials`,
|
2019-06-11 15:13:48 +00:00
|
|
|
method: 'get',
|
2019-03-22 21:18:57 +00:00
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function fetchUserStatuses(id, authHost, godmode, token) {
|
2019-09-23 19:00:28 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`,
|
2019-09-23 19:00:28 +00:00
|
|
|
method: 'get',
|
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-28 13:06:49 +00:00
|
|
|
export async function forcePasswordReset(nicknames, authHost, token) {
|
2019-09-24 22:55:42 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-01-28 13:06:49 +00:00
|
|
|
url: `/api/pleroma/admin/users/force_password_reset`,
|
2019-09-24 22:55:42 +00:00
|
|
|
method: 'patch',
|
2020-01-28 13:06:49 +00:00
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { nicknames }
|
2019-09-24 22:55:42 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function getPasswordResetToken(nickname, authHost, token) {
|
2019-03-22 21:18:57 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: `/api/pleroma/admin/users/${nickname}/password_reset`,
|
2019-06-11 15:13:48 +00:00
|
|
|
method: 'get',
|
2019-03-22 21:18:57 +00:00
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function listAllTags(authHost, token) {
|
2019-03-22 21:18:57 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: `/api/pleroma/admin/users/tag`,
|
|
|
|
method: 'get',
|
|
|
|
headers: authHeaders(token)
|
2019-03-22 21:18:57 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function resendConfirmationEmail(nicknames, authHost, token) {
|
2019-03-22 21:18:57 +00:00
|
|
|
return await request({
|
2019-03-23 14:09:48 +00:00
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: '/api/pleroma/admin/users/resend_confirmation_email',
|
|
|
|
method: 'patch',
|
2019-03-22 21:18:57 +00:00
|
|
|
headers: authHeaders(token),
|
2020-10-03 10:29:34 +00:00
|
|
|
data: { nicknames }
|
2019-03-22 21:18:57 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function searchUsers(query, filters, authHost, token, page = 1) {
|
2019-07-24 20:50:45 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: `/api/pleroma/admin/users?query=${query}&page=${page}&filters=${filters}`,
|
2019-07-24 20:50:45 +00:00
|
|
|
method: 'get',
|
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function tagUser(nicknames, tags, authHost, token) {
|
2020-08-05 22:53:23 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: '/api/pleroma/admin/users/tag',
|
|
|
|
method: 'put',
|
2020-08-05 22:53:23 +00:00
|
|
|
headers: authHeaders(token),
|
2020-10-03 10:29:34 +00:00
|
|
|
data: { nicknames, tags }
|
2020-08-05 22:53:23 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function untagUser(nicknames, tags, authHost, token) {
|
2019-11-19 11:15:15 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: '/api/pleroma/admin/users/tag',
|
|
|
|
method: 'delete',
|
2019-11-19 11:15:15 +00:00
|
|
|
headers: authHeaders(token),
|
2020-10-03 10:29:34 +00:00
|
|
|
data: { nicknames, tags }
|
2019-11-19 11:15:15 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-03 10:29:34 +00:00
|
|
|
export async function updateUserCredentials(nickname, credentials, authHost, token) {
|
2019-11-19 11:15:15 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-10-03 10:29:34 +00:00
|
|
|
url: `/api/pleroma/admin/users/${nickname}/credentials`,
|
2019-11-19 11:15:15 +00:00
|
|
|
method: 'patch',
|
|
|
|
headers: authHeaders(token),
|
2020-10-03 10:29:34 +00:00
|
|
|
data: credentials
|
2019-11-19 11:15:15 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:18:57 +00:00
|
|
|
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
|