1 import { AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, AbuseVideoIs } from '@shared/models'
2 import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
3 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
5 function reportAbuse (options: {
15 predefinedReasons?: AbusePredefinedReasonsString[]
20 statusCodeExpected?: number
22 const path = '/api/v1/abuses'
24 const video = options.videoId ? {
26 startAt: options.startAt,
30 const comment = options.commentId ? {
34 const account = options.accountId ? {
43 reason: options.reason,
44 predefinedReasons: options.predefinedReasons
47 return makePostBodyRequest({
53 statusCodeExpected: options.statusCodeExpected || HttpStatusCode.OK_200
57 function getAdminAbusesList (options: {
66 predefinedReason?: AbusePredefinedReasonsString
70 videoIs?: AbuseVideoIs
71 searchReporter?: string
72 searchReportee?: string
74 searchVideoChannel?: string
93 const path = '/api/v1/abuses'
104 sort: sort || 'createdAt',
111 return makeGetRequest({
116 statusCodeExpected: HttpStatusCode.OK_200
120 function getUserAbusesList (options: {
142 const path = '/api/v1/users/me/abuses'
150 sort: sort || 'createdAt'
153 return makeGetRequest({
158 statusCodeExpected: HttpStatusCode.OK_200
162 function updateAbuse (
167 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
169 const path = '/api/v1/abuses/' + abuseId
171 return makePutBodyRequest({
180 function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
181 const path = '/api/v1/abuses/' + abuseId
183 return makeDeleteRequest({
191 function listAbuseMessages (url: string, token: string, abuseId: number, statusCodeExpected = HttpStatusCode.OK_200) {
192 const path = '/api/v1/abuses/' + abuseId + '/messages'
194 return makeGetRequest({
202 function deleteAbuseMessage (
207 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
209 const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId
211 return makeDeleteRequest({
219 function addAbuseMessage (url: string, token: string, abuseId: number, message: string, statusCodeExpected = HttpStatusCode.OK_200) {
220 const path = '/api/v1/abuses/' + abuseId + '/messages'
222 return makePostBodyRequest({
231 // ---------------------------------------------------------------------------