Add module for status

This commit is contained in:
Angelina Filippova 2019-10-04 00:20:48 +03:00
parent 9f99dea72f
commit 2ea990f074
5 changed files with 43 additions and 28 deletions

View file

@ -12,25 +12,6 @@ export async function changeState(state, id, authHost, token) {
})
}
export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/statuses/${id}`,
method: 'put',
headers: authHeaders(token),
data: { sensitive, visibility }
})
}
export async function deleteStatus(id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/statuses/${id}`,
method: 'delete',
headers: authHeaders(token)
})
}
export async function fetchReports(filter, page, pageSize, authHost, token) {
const url = filter.length > 0
? `/api/pleroma/admin/reports?state=${filter}&page=${page}&page_size=${pageSize}`

24
src/api/status.js Normal file
View file

@ -0,0 +1,24 @@
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/statuses/${id}`,
method: 'put',
headers: authHeaders(token),
data: { sensitive, visibility }
})
}
export async function deleteStatus(id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/statuses/${id}`,
method: 'delete',
headers: authHeaders(token)
})
}
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}

View file

@ -6,6 +6,7 @@ import invites from './modules/invites'
import permission from './modules/permission'
import reports from './modules/reports'
import settings from './modules/settings'
import status from './modules/status'
import tagsView from './modules/tagsView'
import user from './modules/user'
import userProfile from './modules/userProfile'
@ -23,6 +24,7 @@ const store = new Vuex.Store({
permission,
reports,
settings,
status,
tagsView,
user,
userProfile,

View file

@ -1,4 +1,4 @@
import { changeState, changeStatusScope, deleteStatus, fetchReports } from '@/api/reports'
import { changeState, fetchReports } from '@/api/reports'
const reports = {
state: {
@ -38,18 +38,10 @@ const reports = {
await changeState(reportState, reportId, getters.authHost, getters.token)
dispatch('FetchReports', state.currentPage)
},
async ChangeStatusScope({ dispatch, getters, state }, { statusId, isSensitive, visibility }) {
await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token)
dispatch('FetchReports', state.currentPage)
},
ClearFetchedReports({ commit }) {
commit('SET_REPORTS', [])
commit('SET_LAST_REPORT_ID', '')
},
async DeleteStatus({ dispatch, getters, state }, { statusId }) {
await deleteStatus(statusId, getters.authHost, getters.token)
dispatch('FetchReports', state.currentPage)
},
async FetchReports({ commit, getters, state }, page) {
commit('SET_LOADING', true)
const { data } = await fetchReports(state.stateFilter, page, state.pageSize, getters.authHost, getters.token)

View file

@ -0,0 +1,16 @@
import { changeStatusScope, deleteStatus } from '@/api/status'
const status = {
actions: {
async ChangeStatusScope({ dispatch, getters, state }, { statusId, isSensitive, visibility }) {
await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token)
dispatch('FetchReports', state.currentPage)
},
async DeleteStatus({ dispatch, getters, state }, { statusId }) {
await deleteStatus(statusId, getters.authHost, getters.token)
dispatch('FetchReports', state.currentPage)
}
}
}
export default status