diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/lib/activitypub/process/process-like.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip |
Move models to typescript-sequelize
Diffstat (limited to 'server/lib/activitypub/process/process-like.ts')
-rw-r--r-- | server/lib/activitypub/process/process-like.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts index 5f2ffe7ea..a6e391f1e 100644 --- a/server/lib/activitypub/process/process-like.ts +++ b/server/lib/activitypub/process/process-like.ts | |||
@@ -1,7 +1,9 @@ | |||
1 | import { ActivityLike } from '../../../../shared/models/activitypub/activity' | 1 | import { ActivityLike } from '../../../../shared/models/activitypub' |
2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 2 | import { retryTransactionWrapper } from '../../../helpers' |
3 | import { database as db } from '../../../initializers' | 3 | import { sequelizeTypescript } from '../../../initializers' |
4 | import { AccountInstance } from '../../../models/account/account-interface' | 4 | import { AccountModel } from '../../../models/account/account' |
5 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | ||
6 | import { VideoModel } from '../../../models/video/video' | ||
5 | import { getOrCreateAccountAndServer } from '../account' | 7 | import { getOrCreateAccountAndServer } from '../account' |
6 | import { forwardActivity } from '../send/misc' | 8 | import { forwardActivity } from '../send/misc' |
7 | 9 | ||
@@ -19,7 +21,7 @@ export { | |||
19 | 21 | ||
20 | // --------------------------------------------------------------------------- | 22 | // --------------------------------------------------------------------------- |
21 | 23 | ||
22 | async function processLikeVideo (byAccount: AccountInstance, activity: ActivityLike) { | 24 | async function processLikeVideo (byAccount: AccountModel, activity: ActivityLike) { |
23 | const options = { | 25 | const options = { |
24 | arguments: [ byAccount, activity ], | 26 | arguments: [ byAccount, activity ], |
25 | errorMessage: 'Cannot like the video with many retries.' | 27 | errorMessage: 'Cannot like the video with many retries.' |
@@ -28,11 +30,11 @@ async function processLikeVideo (byAccount: AccountInstance, activity: ActivityL | |||
28 | return retryTransactionWrapper(createVideoLike, options) | 30 | return retryTransactionWrapper(createVideoLike, options) |
29 | } | 31 | } |
30 | 32 | ||
31 | function createVideoLike (byAccount: AccountInstance, activity: ActivityLike) { | 33 | function createVideoLike (byAccount: AccountModel, activity: ActivityLike) { |
32 | const videoUrl = activity.object | 34 | const videoUrl = activity.object |
33 | 35 | ||
34 | return db.sequelize.transaction(async t => { | 36 | return sequelizeTypescript.transaction(async t => { |
35 | const video = await db.Video.loadByUrlAndPopulateAccount(videoUrl) | 37 | const video = await VideoModel.loadByUrlAndPopulateAccount(videoUrl) |
36 | 38 | ||
37 | if (!video) throw new Error('Unknown video ' + videoUrl) | 39 | if (!video) throw new Error('Unknown video ' + videoUrl) |
38 | 40 | ||
@@ -41,7 +43,7 @@ function createVideoLike (byAccount: AccountInstance, activity: ActivityLike) { | |||
41 | videoId: video.id, | 43 | videoId: video.id, |
42 | accountId: byAccount.id | 44 | accountId: byAccount.id |
43 | } | 45 | } |
44 | const [ , created ] = await db.AccountVideoRate.findOrCreate({ | 46 | const [ , created ] = await AccountVideoRateModel.findOrCreate({ |
45 | where: rate, | 47 | where: rate, |
46 | defaults: rate, | 48 | defaults: rate, |
47 | transaction: t | 49 | transaction: t |