]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/express-utils.ts
Add outbox page size parameter
[github/Chocobozzz/PeerTube.git] / server / helpers / express-utils.ts
index e0a1d56a587759adad40cdec568594b2ee41900a..9bf6d85a87a21f76338090a551cabb425e4dd463 100644 (file)
@@ -74,7 +74,18 @@ function createReqFiles (
     },
 
     filename: async (req, file, cb) => {
-      const extension = mimeTypes[ file.mimetype ] || extname(file.originalname)
+      let extension: string
+      const fileExtension = extname(file.originalname)
+      const extensionFromMimetype = mimeTypes[ file.mimetype ]
+
+      // Take the file extension if we don't understand the mime type
+      // We have the OGG/OGV exception too because firefox sends a bad mime type when sending an OGG file
+      if (fileExtension === '.ogg' || fileExtension === '.ogv' || !extensionFromMimetype) {
+        extension = fileExtension
+      } else {
+        extension = extensionFromMimetype
+      }
+
       let randomString = ''
 
       try {
@@ -106,6 +117,10 @@ function isUserAbleToSearchRemoteURI (res: express.Response) {
     (CONFIG.SEARCH.REMOTE_URI.USERS === true && user !== undefined)
 }
 
+function getCountVideos (req: express.Request) {
+  return req.query.skipCount !== true
+}
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -114,5 +129,6 @@ export {
   isUserAbleToSearchRemoteURI,
   badRequest,
   createReqFiles,
-  cleanUpReqFiles
+  cleanUpReqFiles,
+  getCountVideos
 }