aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-like.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/process/process-like.ts')
-rw-r--r--server/lib/activitypub/process/process-like.ts20
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 @@
1import { ActivityLike } from '../../../../shared/models/activitypub/activity' 1import { ActivityLike } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { retryTransactionWrapper } from '../../../helpers'
3import { database as db } from '../../../initializers' 3import { sequelizeTypescript } from '../../../initializers'
4import { AccountInstance } from '../../../models/account/account-interface' 4import { AccountModel } from '../../../models/account/account'
5import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
6import { VideoModel } from '../../../models/video/video'
5import { getOrCreateAccountAndServer } from '../account' 7import { getOrCreateAccountAndServer } from '../account'
6import { forwardActivity } from '../send/misc' 8import { forwardActivity } from '../send/misc'
7 9
@@ -19,7 +21,7 @@ export {
19 21
20// --------------------------------------------------------------------------- 22// ---------------------------------------------------------------------------
21 23
22async function processLikeVideo (byAccount: AccountInstance, activity: ActivityLike) { 24async 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
31function createVideoLike (byAccount: AccountInstance, activity: ActivityLike) { 33function 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