diff options
Diffstat (limited to 'server/lib/activitypub/process/process-announce.ts')
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 2aa9ad5c7..ff2c6d708 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { ActivityAdd, ActivityAnnounce, ActivityCreate } from '../../../../shared/models/activitypub/activity' | 1 | import { ActivityAdd, ActivityAnnounce, ActivityCreate } from '../../../../shared/models/activitypub' |
2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 2 | import { logger, retryTransactionWrapper } from '../../../helpers' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { sequelizeTypescript } from '../../../initializers' |
4 | import { database as db } from '../../../initializers/index' | 4 | import { AccountModel } from '../../../models/account/account' |
5 | import { AccountInstance } from '../../../models/account/account-interface' | 5 | import { VideoModel } from '../../../models/video/video' |
6 | import { VideoInstance } from '../../../models/index' | 6 | import { VideoChannelModel } from '../../../models/video/video-channel' |
7 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' | 7 | import { VideoChannelShareModel } from '../../../models/video/video-channel-share' |
8 | import { VideoShareModel } from '../../../models/video/video-share' | ||
8 | import { getOrCreateAccountAndServer } from '../account' | 9 | import { getOrCreateAccountAndServer } from '../account' |
9 | import { forwardActivity } from '../send/misc' | 10 | import { forwardActivity } from '../send/misc' |
10 | import { processAddActivity } from './process-add' | 11 | import { processAddActivity } from './process-add' |
@@ -36,7 +37,7 @@ export { | |||
36 | 37 | ||
37 | // --------------------------------------------------------------------------- | 38 | // --------------------------------------------------------------------------- |
38 | 39 | ||
39 | function processVideoChannelShare (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { | 40 | function processVideoChannelShare (accountAnnouncer: AccountModel, activity: ActivityAnnounce) { |
40 | const options = { | 41 | const options = { |
41 | arguments: [ accountAnnouncer, activity ], | 42 | arguments: [ accountAnnouncer, activity ], |
42 | errorMessage: 'Cannot share the video channel with many retries.' | 43 | errorMessage: 'Cannot share the video channel with many retries.' |
@@ -45,18 +46,18 @@ function processVideoChannelShare (accountAnnouncer: AccountInstance, activity: | |||
45 | return retryTransactionWrapper(shareVideoChannel, options) | 46 | return retryTransactionWrapper(shareVideoChannel, options) |
46 | } | 47 | } |
47 | 48 | ||
48 | async function shareVideoChannel (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { | 49 | async function shareVideoChannel (accountAnnouncer: AccountModel, activity: ActivityAnnounce) { |
49 | const announcedActivity = activity.object as ActivityCreate | 50 | const announcedActivity = activity.object as ActivityCreate |
50 | 51 | ||
51 | return db.sequelize.transaction(async t => { | 52 | return sequelizeTypescript.transaction(async t => { |
52 | // Add share entry | 53 | // Add share entry |
53 | const videoChannel: VideoChannelInstance = await processCreateActivity(announcedActivity) | 54 | const videoChannel: VideoChannelModel = await processCreateActivity(announcedActivity) |
54 | const share = { | 55 | const share = { |
55 | accountId: accountAnnouncer.id, | 56 | accountId: accountAnnouncer.id, |
56 | videoChannelId: videoChannel.id | 57 | videoChannelId: videoChannel.id |
57 | } | 58 | } |
58 | 59 | ||
59 | const [ , created ] = await db.VideoChannelShare.findOrCreate({ | 60 | const [ , created ] = await VideoChannelShareModel.findOrCreate({ |
60 | where: share, | 61 | where: share, |
61 | defaults: share, | 62 | defaults: share, |
62 | transaction: t | 63 | transaction: t |
@@ -72,7 +73,7 @@ async function shareVideoChannel (accountAnnouncer: AccountInstance, activity: A | |||
72 | }) | 73 | }) |
73 | } | 74 | } |
74 | 75 | ||
75 | function processVideoShare (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { | 76 | function processVideoShare (accountAnnouncer: AccountModel, activity: ActivityAnnounce) { |
76 | const options = { | 77 | const options = { |
77 | arguments: [ accountAnnouncer, activity ], | 78 | arguments: [ accountAnnouncer, activity ], |
78 | errorMessage: 'Cannot share the video with many retries.' | 79 | errorMessage: 'Cannot share the video with many retries.' |
@@ -81,19 +82,19 @@ function processVideoShare (accountAnnouncer: AccountInstance, activity: Activit | |||
81 | return retryTransactionWrapper(shareVideo, options) | 82 | return retryTransactionWrapper(shareVideo, options) |
82 | } | 83 | } |
83 | 84 | ||
84 | function shareVideo (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { | 85 | function shareVideo (accountAnnouncer: AccountModel, activity: ActivityAnnounce) { |
85 | const announcedActivity = activity.object as ActivityAdd | 86 | const announcedActivity = activity.object as ActivityAdd |
86 | 87 | ||
87 | return db.sequelize.transaction(async t => { | 88 | return sequelizeTypescript.transaction(async t => { |
88 | // Add share entry | 89 | // Add share entry |
89 | const video: VideoInstance = await processAddActivity(announcedActivity) | 90 | const video: VideoModel = await processAddActivity(announcedActivity) |
90 | 91 | ||
91 | const share = { | 92 | const share = { |
92 | accountId: accountAnnouncer.id, | 93 | accountId: accountAnnouncer.id, |
93 | videoId: video.id | 94 | videoId: video.id |
94 | } | 95 | } |
95 | 96 | ||
96 | const [ , created ] = await db.VideoShare.findOrCreate({ | 97 | const [ , created ] = await VideoShareModel.findOrCreate({ |
97 | where: share, | 98 | where: share, |
98 | defaults: share, | 99 | defaults: share, |
99 | transaction: t | 100 | transaction: t |