]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/requests/requests.ts
Hide schedule privacy if private does not exist
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / requests / requests.ts
index 3e773ee036109e1221a36cdbdca4fccd80043533..38e24d89716967b8c9fc04da1177a11d603885ad 100644 (file)
@@ -26,6 +26,7 @@ function makeGetRequest (options: {
   contentType?: string
   range?: string
   redirects?: number
+  accept?: string
 }) {
   if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
   if (options.contentType === undefined) options.contentType = 'application/json'
@@ -36,6 +37,7 @@ function makeGetRequest (options: {
   if (options.token) req.set('Authorization', 'Bearer ' + options.token)
   if (options.query) req.query(options.query)
   if (options.range) req.set('Range', options.range)
+  if (options.accept) req.set('Accept', options.accept)
   if (options.redirects) req.redirects(options.redirects)
 
   return req.expect(options.statusCodeExpected)
@@ -152,11 +154,12 @@ function makeHTMLRequest (url: string, path: string) {
     .expect(HttpStatusCode.OK_200)
 }
 
-function updateAvatarRequest (options: {
+function updateImageRequest (options: {
   url: string
   path: string
   accessToken: string
   fixture: string
+  fieldname: string
 }) {
   let filePath = ''
   if (isAbsolute(options.fixture)) {
@@ -170,7 +173,7 @@ function updateAvatarRequest (options: {
     path: options.path,
     token: options.accessToken,
     fields: {},
-    attaches: { avatarfile: filePath },
+    attaches: { [options.fieldname]: filePath },
     statusCodeExpected: HttpStatusCode.OK_200
   })
 }
@@ -191,5 +194,5 @@ export {
   makePutBodyRequest,
   makeDeleteRequest,
   makeRawRequest,
-  updateAvatarRequest
+  updateImageRequest
 }