]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/server/redundancy.ts
Translated using Weblate (Bengali)
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / server / redundancy.ts
index 7b488e23e15423441b2cf5993c6ded0ff65bf623..b83815a370907c21b34fc5d814bf96a01b769400 100644 (file)
@@ -1,7 +1,14 @@
 import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
 import { VideoRedundanciesTarget } from '@shared/models'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 
-function updateRedundancy (url: string, accessToken: string, host: string, redundancyAllowed: boolean, expectedStatus = 204) {
+function updateRedundancy (
+  url: string,
+  accessToken: string,
+  host: string,
+  redundancyAllowed: boolean,
+  expectedStatus = HttpStatusCode.NO_CONTENT_204
+) {
   const path = '/api/v1/server/redundancy/' + host
 
   return makePutBodyRequest({
@@ -15,12 +22,12 @@ function updateRedundancy (url: string, accessToken: string, host: string, redun
 
 function listVideoRedundancies (options: {
   url: string
-  accessToken: string,
-  target: VideoRedundanciesTarget,
-  start?: number,
-  count?: number,
-  sort?: string,
-  statusCodeExpected?: number
+  accessToken: string
+  target: VideoRedundanciesTarget
+  start?: number
+  count?: number
+  sort?: string
+  statusCodeExpected?: HttpStatusCode
 }) {
   const path = '/api/v1/server/redundancy/videos'
 
@@ -36,13 +43,13 @@ function listVideoRedundancies (options: {
       sort: sort ?? 'name',
       target
     },
-    statusCodeExpected: statusCodeExpected || 200
+    statusCodeExpected: statusCodeExpected || HttpStatusCode.OK_200
   })
 }
 
 function addVideoRedundancy (options: {
-  url: string,
-  accessToken: string,
+  url: string
+  accessToken: string
   videoId: number
 }) {
   const path = '/api/v1/server/redundancy/videos'
@@ -53,13 +60,13 @@ function addVideoRedundancy (options: {
     token: accessToken,
     path,
     fields: { videoId },
-    statusCodeExpected: 204
+    statusCodeExpected: HttpStatusCode.NO_CONTENT_204
   })
 }
 
 function removeVideoRedundancy (options: {
-  url: string,
-  accessToken: string,
+  url: string
+  accessToken: string
   redundancyId: number
 }) {
   const { url, accessToken, redundancyId } = options
@@ -69,7 +76,7 @@ function removeVideoRedundancy (options: {
     url,
     token: accessToken,
     path,
-    statusCodeExpected: 204
+    statusCodeExpected: HttpStatusCode.NO_CONTENT_204
   })
 }