Add api for fetching a list of tags

This commit is contained in:
Angelina Filippova 2020-10-03 13:29:34 +03:00
parent 457264b72c
commit 37b2fb3199
3 changed files with 67 additions and 48 deletions

View file

@ -22,6 +22,26 @@ export async function addRight(nicknames, right, authHost, token) {
})
}
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 }
})
}
export async function createNewAccount(nickname, email, password, authHost, token) {
return await request({
baseURL: baseName(authHost),
@ -81,6 +101,15 @@ export async function fetchUser(id, authHost, token) {
})
}
export async function fetchUsers(filters, authHost, token, page = 1) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function fetchUserCredentials(nickname, authHost, token) {
return await request({
baseURL: baseName(authHost),
@ -90,22 +119,22 @@ export async function fetchUserCredentials(nickname, authHost, token) {
})
}
export async function updateUserCredentials(nickname, credentials, authHost, token) {
export async function fetchUserStatuses(id, authHost, godmode, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users/${nickname}/credentials`,
method: 'patch',
headers: authHeaders(token),
data: credentials
url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function fetchUsers(filters, authHost, token, page = 1) {
export async function forcePasswordReset(nicknames, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
method: 'get',
headers: authHeaders(token)
url: `/api/pleroma/admin/users/force_password_reset`,
method: 'patch',
headers: authHeaders(token),
data: { nicknames }
})
}
@ -118,10 +147,19 @@ export async function getPasswordResetToken(nickname, authHost, token) {
})
}
export async function forcePasswordReset(nicknames, authHost, token) {
export async function listAllTags(authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users/force_password_reset`,
url: `/api/pleroma/admin/users/tag`,
method: 'get',
headers: authHeaders(token)
})
}
export async function resendConfirmationEmail(nicknames, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: '/api/pleroma/admin/users/resend_confirmation_email',
method: 'patch',
headers: authHeaders(token),
data: { nicknames }
@ -157,42 +195,13 @@ export async function untagUser(nicknames, tags, authHost, token) {
})
}
export async function fetchUserStatuses(id, authHost, godmode, token) {
export async function updateUserCredentials(nickname, credentials, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function approveUserAccount(nicknames, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: '/api/pleroma/admin/users/approve',
url: `/api/pleroma/admin/users/${nickname}/credentials`,
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 }
})
}
export async function resendConfirmationEmail(nicknames, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: '/api/pleroma/admin/users/resend_confirmation_email',
method: 'patch',
headers: authHeaders(token),
data: { nicknames }
data: credentials
})
}

View file

@ -3,20 +3,21 @@ import i18n from '@/lang'
import {
activateUsers,
addRight,
approveUserAccount,
confirmUserEmail,
createNewAccount,
deactivateUsers,
deleteRight,
deleteUsers,
disableMfa,
fetchUsers,
forcePasswordReset,
getPasswordResetToken,
listAllTags,
resendConfirmationEmail,
searchUsers,
tagUser,
untagUser,
forcePasswordReset,
approveUserAccount,
confirmUserEmail,
resendConfirmationEmail,
updateUserCredentials
} from '@/api/users'
import { fetchSettings, updateSettings } from '@/api/settings'
@ -40,7 +41,8 @@ const users = {
passwordResetToken: {
token: '',
link: ''
}
},
tags: []
},
mutations: {
SET_USERS: (state, users) => {
@ -83,6 +85,9 @@ const users = {
SET_TAG_POLICY: (state, mrfPolicies) => {
state.mrfPolicies = mrfPolicies
},
SET_TAGS: (state, tags) => {
state.tags = tags
},
SET_USERS_FILTERS: (state, filters) => {
state.filters = filters
}
@ -246,6 +251,10 @@ const users = {
RemovePasswordToken({ commit }) {
commit('SET_PASSWORD_RESET_TOKEN', { link: '', token: '' })
},
async ListTags({ commit, getters }) {
const { data } = await listAllTags(getters.authHost, getters.token)
commit('SET_TAGS', data)
},
async RemoveTag({ dispatch, getters }, { users, tag, _userId, _statusId }) {
const updatedUsers = users.map(user => {
return { ...user, tags: user.tags.filter(userTag => userTag !== tag) }

View file

@ -226,6 +226,7 @@ export default {
this.$store.dispatch('NeedReboot')
this.$store.dispatch('FetchTagPolicySetting')
this.$store.dispatch('FetchUsers', { page: 1 })
this.$store.dispatch('ListTags')
},
destroyed() {
this.$store.dispatch('ClearUsersState')