-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()
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