-import { resetSequelizeInstance } from '../../../helpers/utils'
-import { database as db } from '../../../initializers'
-import { AccountInstance } from '../../../models/account/account-interface'
-import { VideoInstance } from '../../../models/video/video-interface'
-import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc'
-import Bluebird = require('bluebird')
-
-async function processUpdateActivity (activity: ActivityUpdate) {
- const account = await getOrCreateAccount(activity.actor)
-
- if (activity.object.type === 'Video') {
- return processUpdateVideo(account, activity.object)
- } else if (activity.object.type === 'VideoChannel') {
- return processUpdateVideoChannel(account, activity.object)
+import { sequelizeTypescript } from '../../../initializers'
+import { AccountModel } from '../../../models/account/account'
+import { ActorModel } from '../../../models/activitypub/actor'
+import { VideoChannelModel } from '../../../models/video/video-channel'
+import { getAvatarInfoIfExists, updateActorAvatarInstance, updateActorInstance } from '../actor'
+import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos'
+import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos'
+import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file'
+import { createOrUpdateCacheFile } from '../cache-file'
+import { forwardVideoRelatedActivity } from '../send/utils'
+import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
+import { createOrUpdateVideoPlaylist } from '../playlist'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
+import { MActorSignature } from '../../../typings/models'
+
+async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) {
+ const { activity, byActor } = options
+
+ const objectType = activity.object.type
+
+ if (objectType === 'Video') {
+ return retryTransactionWrapper(processUpdateVideo, byActor, activity)
+ }
+
+ if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') {
+ // We need more attributes
+ const byActorFull = await ActorModel.loadByUrlAndPopulateAccountAndChannel(byActor.url)
+ return retryTransactionWrapper(processUpdateActor, byActorFull, activity)
+ }
+
+ if (objectType === 'CacheFile') {
+ // We need more attributes
+ const byActorFull = await ActorModel.loadByUrlAndPopulateAccountAndChannel(byActor.url)
+ return retryTransactionWrapper(processUpdateCacheFile, byActorFull, activity)
+ }
+
+ if (objectType === 'Playlist') {
+ return retryTransactionWrapper(processUpdatePlaylist, byActor, activity)