Skip to content
Snippets Groups Projects
status.js 1.93 KiB
Newer Older
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only

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)
  })
}

export async function fetchStatus(id, authHost, token) {
  return await request({
    baseURL: baseName(authHost),
    url: `/api/pleroma/admin/statuses/${id}`,
    method: 'get',
    headers: authHeaders(token)
  })
export async function fetchStatuses({ godmode, localOnly, authHost, token, pageSize, page }) {
  return await request({
    baseURL: baseName(authHost),
    url: `/api/pleroma/admin/statuses?godmode=${godmode}&local_only=${localOnly}&page=${page}&page_size=${pageSize}`,
    method: 'get',
    headers: authHeaders(token)
  })
}

export async function fetchStatusesCount(instance, authHost, token) {
  return await request({
    baseURL: baseName(authHost),
    url: instance ? `/api/pleroma/admin/stats?instance=${instance}` : `/api/pleroma/admin/stats`,
export async function fetchStatusesByInstance({ instance, authHost, token, pageSize, page }) {
Maxim Filippov's avatar
Maxim Filippov committed
  return await request({
    baseURL: baseName(authHost),
Maxim Filippov's avatar
Maxim Filippov committed
    url: `/api/pleroma/admin/instances/${instance}/statuses?page=${page}&page_size=${pageSize}`,
Maxim Filippov's avatar
Maxim Filippov committed
    method: 'get',
    headers: authHeaders(token)
  })
}

const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}