import * as Bluebird from 'bluebird'
import { VideoTorrentObject } from '../../../../shared'
import { ActivityAdd } from '../../../../shared/models/activitypub/activity'
-import { generateThumbnailFromUrl, getOrCreateAccount, logger, retryTransactionWrapper } from '../../../helpers'
-import { getOrCreateVideoChannel } from '../../../helpers/activitypub'
+import { retryTransactionWrapper } from '../../../helpers/database-utils'
+import { logger } from '../../../helpers/logger'
import { database as db } from '../../../initializers'
import { AccountInstance } from '../../../models/account/account-interface'
import { VideoChannelInstance } from '../../../models/video/video-channel-interface'
+import { getOrCreateAccountAndServer } from '../account'
+import { getOrCreateVideoChannel } from '../video-channels'
+import { generateThumbnailFromUrl } from '../videos'
import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc'
async function processAddActivity (activity: ActivityAdd) {
const activityObject = activity.object
const activityType = activityObject.type
- const account = await getOrCreateAccount(activity.actor)
+ const account = await getOrCreateAccountAndServer(activity.actor)
if (activityType === 'Video') {
const videoChannelUrl = activity.target
return retryTransactionWrapper(addRemoteVideo, options)
}
-function addRemoteVideo (
- account: AccountInstance,
- activity: ActivityAdd,
- videoChannel: VideoChannelInstance,
- videoToCreateData: VideoTorrentObject
-) {
+function addRemoteVideo (account: AccountInstance,
+ activity: ActivityAdd,
+ videoChannel: VideoChannelInstance,
+ videoToCreateData: VideoTorrentObject) {
logger.debug('Adding remote video %s.', videoToCreateData.url)
return db.sequelize.transaction(async t => {