aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/moderation/abuses.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /shared/extra-utils/moderation/abuses.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'shared/extra-utils/moderation/abuses.ts')
-rw-r--r--shared/extra-utils/moderation/abuses.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/shared/extra-utils/moderation/abuses.ts b/shared/extra-utils/moderation/abuses.ts
index 7db75cebb..cb6ca46ef 100644
--- a/shared/extra-utils/moderation/abuses.ts
+++ b/shared/extra-utils/moderation/abuses.ts
@@ -1,6 +1,6 @@
1
2import { AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, AbuseVideoIs } from '@shared/models' 1import { AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, AbuseVideoIs } from '@shared/models'
3import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' 2import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4 4
5function reportAbuse (options: { 5function reportAbuse (options: {
6 url: string 6 url: string
@@ -50,7 +50,7 @@ function reportAbuse (options: {
50 token: options.token, 50 token: options.token,
51 51
52 fields: body, 52 fields: body,
53 statusCodeExpected: options.statusCodeExpected || 200 53 statusCodeExpected: options.statusCodeExpected || HttpStatusCode.OK_200
54 }) 54 })
55} 55}
56 56
@@ -113,7 +113,7 @@ function getAdminAbusesList (options: {
113 path, 113 path,
114 token, 114 token,
115 query, 115 query,
116 statusCodeExpected: 200 116 statusCodeExpected: HttpStatusCode.OK_200
117 }) 117 })
118} 118}
119 119
@@ -155,7 +155,7 @@ function getUserAbusesList (options: {
155 path, 155 path,
156 token, 156 token,
157 query, 157 query,
158 statusCodeExpected: 200 158 statusCodeExpected: HttpStatusCode.OK_200
159 }) 159 })
160} 160}
161 161
@@ -164,7 +164,7 @@ function updateAbuse (
164 token: string, 164 token: string,
165 abuseId: number, 165 abuseId: number,
166 body: AbuseUpdate, 166 body: AbuseUpdate,
167 statusCodeExpected = 204 167 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
168) { 168) {
169 const path = '/api/v1/abuses/' + abuseId 169 const path = '/api/v1/abuses/' + abuseId
170 170
@@ -177,7 +177,7 @@ function updateAbuse (
177 }) 177 })
178} 178}
179 179
180function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExpected = 204) { 180function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
181 const path = '/api/v1/abuses/' + abuseId 181 const path = '/api/v1/abuses/' + abuseId
182 182
183 return makeDeleteRequest({ 183 return makeDeleteRequest({
@@ -188,7 +188,7 @@ function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExp
188 }) 188 })
189} 189}
190 190
191function listAbuseMessages (url: string, token: string, abuseId: number, statusCodeExpected = 200) { 191function listAbuseMessages (url: string, token: string, abuseId: number, statusCodeExpected = HttpStatusCode.OK_200) {
192 const path = '/api/v1/abuses/' + abuseId + '/messages' 192 const path = '/api/v1/abuses/' + abuseId + '/messages'
193 193
194 return makeGetRequest({ 194 return makeGetRequest({
@@ -199,7 +199,13 @@ function listAbuseMessages (url: string, token: string, abuseId: number, statusC
199 }) 199 })
200} 200}
201 201
202function deleteAbuseMessage (url: string, token: string, abuseId: number, messageId: number, statusCodeExpected = 204) { 202function deleteAbuseMessage (
203 url: string,
204 token: string,
205 abuseId: number,
206 messageId: number,
207 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
208) {
203 const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId 209 const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId
204 210
205 return makeDeleteRequest({ 211 return makeDeleteRequest({
@@ -210,7 +216,7 @@ function deleteAbuseMessage (url: string, token: string, abuseId: number, messag
210 }) 216 })
211} 217}
212 218
213function addAbuseMessage (url: string, token: string, abuseId: number, message: string, statusCodeExpected = 200) { 219function addAbuseMessage (url: string, token: string, abuseId: number, message: string, statusCodeExpected = HttpStatusCode.OK_200) {
214 const path = '/api/v1/abuses/' + abuseId + '/messages' 220 const path = '/api/v1/abuses/' + abuseId + '/messages'
215 221
216 return makePostBodyRequest({ 222 return makePostBodyRequest({