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
27 startAt: options.startAt,
32 const comment = options.commentId
33 ? { id: options.commentId }
36 const account = options.accountId
37 ? { id: options.accountId }
45 reason: options.reason,
46 predefinedReasons: options.predefinedReasons
49 return makePostBodyRequest({
55 statusCodeExpected: options.statusCodeExpected || HttpStatusCode.OK_200
59 function getAdminAbusesList (options: {
68 predefinedReason?: AbusePredefinedReasonsString
72 videoIs?: AbuseVideoIs
73 searchReporter?: string
74 searchReportee?: string
76 searchVideoChannel?: string
95 const path = '/api/v1/abuses'
106 sort: sort || 'createdAt',
113 return makeGetRequest({
118 statusCodeExpected: HttpStatusCode.OK_200
122 function getUserAbusesList (options: {
144 const path = '/api/v1/users/me/abuses'
152 sort: sort || 'createdAt'
155 return makeGetRequest({
160 statusCodeExpected: HttpStatusCode.OK_200
164 function updateAbuse (
169 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
171 const path = '/api/v1/abuses/' + abuseId
173 return makePutBodyRequest({
182 function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
183 const path = '/api/v1/abuses/' + abuseId
185 return makeDeleteRequest({
193 function listAbuseMessages (url: string, token: string, abuseId: number, statusCodeExpected = HttpStatusCode.OK_200) {
194 const path = '/api/v1/abuses/' + abuseId + '/messages'
196 return makeGetRequest({
204 function deleteAbuseMessage (
209 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
211 const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId
213 return makeDeleteRequest({
221 function addAbuseMessage (url: string, token: string, abuseId: number, message: string, statusCodeExpected = HttpStatusCode.OK_200) {
222 const path = '/api/v1/abuses/' + abuseId + '/messages'
224 return makePostBodyRequest({
233 // ---------------------------------------------------------------------------