diff options
Diffstat (limited to 'server/controllers/api/videos/rate.ts')
-rw-r--r-- | server/controllers/api/videos/rate.ts | 20 |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { UserVideoRateUpdate } from '../../../../shared' | 2 | import { UserVideoRateUpdate } from '../../../../shared' |
3 | import { logger, retryTransactionWrapper } from '../../../helpers' | 3 | import { logger, retryTransactionWrapper } from '../../../helpers' |
4 | import { VIDEO_RATE_TYPES } from '../../../initializers' | 4 | import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' |
5 | import { database as db } from '../../../initializers/database' | 5 | import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub' |
6 | import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub/videos' | ||
7 | import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' | 6 | import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' |
8 | import { AccountInstance } from '../../../models/account/account-interface' | 7 | import { AccountModel } from '../../../models/account/account' |
9 | import { VideoInstance } from '../../../models/video/video-interface' | 8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
9 | import { VideoModel } from '../../../models/video/video' | ||
10 | 10 | ||
11 | const rateVideoRouter = express.Router() | 11 | const rateVideoRouter = express.Router() |
12 | 12 | ||
@@ -38,12 +38,12 @@ async function rateVideoRetryWrapper (req: express.Request, res: express.Respons | |||
38 | async function rateVideo (req: express.Request, res: express.Response) { | 38 | async 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 = { |