]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/rate.ts
Prevent broken transcoding with audio only input
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / rate.ts
index 520932c63c028803a74b586032bd2672357612fc..6b26a8eee68b662f7a21d331cbcd59e2a66343a9 100644 (file)
@@ -1,13 +1,12 @@
-import * as express from 'express'
-import { UserVideoRateUpdate } from '../../../../shared'
+import express from 'express'
+import { HttpStatusCode, UserVideoRateUpdate } from '@shared/models'
 import { logger } from '../../../helpers/logger'
 import { VIDEO_RATE_TYPES } from '../../../initializers/constants'
+import { sequelizeTypescript } from '../../../initializers/database'
 import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates'
 import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares'
 import { AccountModel } from '../../../models/account/account'
 import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
-import { sequelizeTypescript } from '../../../initializers/database'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 
 const rateVideoRouter = express.Router()
 
@@ -37,6 +36,9 @@ async function rateVideo (req: express.Request, res: express.Response) {
     const accountInstance = await AccountModel.load(userAccount.id, t)
     const previousRate = await AccountVideoRateModel.load(accountInstance.id, videoInstance.id, t)
 
+    // Same rate, nothing do to
+    if (rateType === 'none' && !previousRate || previousRate?.type === rateType) return
+
     let likesToIncrement = 0
     let dislikesToIncrement = 0