]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-add.ts
Fetch outbox to grab old activities
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-add.ts
index f064c1ab61953e56b9772e2fcf9226c06c843a6b..edc90dee50862890ce0cb43ff2df050a8703bff6 100644 (file)
@@ -1,17 +1,20 @@
 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
@@ -41,12 +44,10 @@ function processAddVideo (account: AccountInstance, activity: ActivityAdd, video
   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 => {