]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/middlewares/abuses.ts
Fix preview upload with capitalized ext
[github/Chocobozzz/PeerTube.git] / server / helpers / middlewares / abuses.ts
index 3906f67604893ad76119ef972e82d472730dd1e4..c53bd9efd9af211bd45709b4ab771df7c1e39bbe 100644 (file)
@@ -1,23 +1,13 @@
 import { Response } from 'express'
 import { AbuseModel } from '../../models/abuse/abuse'
-import { fetchVideo } from '../video'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 
-// FIXME: deprecated in 2.3. Remove this function
-async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
-  const abuseId = parseInt(abuseIdArg + '', 10)
-  let abuse = await AbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
+async function doesAbuseExist (abuseId: number | string, res: Response) {
+  const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
 
   if (!abuse) {
-    const userId = res.locals.oauth?.token.User.id
-    const video = await fetchVideo(videoUUID, 'all', userId)
-
-    if (video) abuse = await AbuseModel.loadByIdAndVideoId(abuseId, video.id)
-  }
-
-  if (abuse === null) {
-    res.status(404)
-       .json({ error: 'Video abuse not found' })
-       .end()
+    res.status(HttpStatusCode.NOT_FOUND_404)
+       .json({ error: 'Abuse not found' })
 
     return false
   }
@@ -26,13 +16,8 @@ async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: stri
   return true
 }
 
-async function doesAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
-
-}
-
 // ---------------------------------------------------------------------------
 
 export {
-  doesAbuseExist,
-  doesVideoAbuseExist
+  doesAbuseExist
 }