aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/rate.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/rate.ts')
-rw-r--r--server/controllers/api/videos/rate.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index c27c61116..48b744b0c 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -1,12 +1,12 @@
1import * as express from 'express' 1import * as express from 'express'
2import { UserVideoRateUpdate } from '../../../../shared' 2import { UserVideoRateUpdate } from '../../../../shared'
3import { logger, retryTransactionWrapper } from '../../../helpers' 3import { logger, retryTransactionWrapper } from '../../../helpers'
4import { VIDEO_RATE_TYPES } from '../../../initializers' 4import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers'
5import { database as db } from '../../../initializers/database' 5import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub'
6import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub/videos'
7import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' 6import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares'
8import { AccountInstance } from '../../../models/account/account-interface' 7import { AccountModel } from '../../../models/account/account'
9import { VideoInstance } from '../../../models/video/video-interface' 8import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9import { VideoModel } from '../../../models/video/video'
10 10
11const rateVideoRouter = express.Router() 11const rateVideoRouter = express.Router()
12 12
@@ -38,12 +38,12 @@ async function rateVideoRetryWrapper (req: express.Request, res: express.Respons
38async function rateVideo (req: express.Request, res: express.Response) { 38async function rateVideo (req: express.Request, res: express.Response) {
39 const body: UserVideoRateUpdate = req.body 39 const body: UserVideoRateUpdate = req.body
40 const rateType = body.rating 40 const rateType = body.rating
41 const videoInstance: VideoInstance = res.locals.video 41 const videoInstance: VideoModel = res.locals.video
42 const accountInstance: AccountInstance = res.locals.oauth.token.User.Account 42 const accountInstance: AccountModel = res.locals.oauth.token.User.Account
43 43
44 await db.sequelize.transaction(async t => { 44 await sequelizeTypescript.transaction(async t => {
45 const sequelizeOptions = { transaction: t } 45 const sequelizeOptions = { transaction: t }
46 const previousRate = await db.AccountVideoRate.load(accountInstance.id, videoInstance.id, t) 46 const previousRate = await AccountVideoRateModel.load(accountInstance.id, videoInstance.id, t)
47 47
48 let likesToIncrement = 0 48 let likesToIncrement = 0
49 let dislikesToIncrement = 0 49 let dislikesToIncrement = 0
@@ -71,7 +71,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
71 type: rateType 71 type: rateType
72 } 72 }
73 73
74 await db.AccountVideoRate.create(query, sequelizeOptions) 74 await AccountVideoRateModel.create(query, sequelizeOptions)
75 } 75 }
76 76
77 const incrementQuery = { 77 const incrementQuery = {