-import { database as db } from '../../../initializers'
-import { AccountInstance } from '../../../models/account/account-interface'
-import { VideoChannelInstance } from '../../../models/video/video-channel-interface'
-import { VideoInstance } from '../../../models/video/video-interface'
-
-async function processDeleteActivity (activity: ActivityDelete) {
- const account = await getOrCreateAccount(activity.actor)
+import { sequelizeTypescript } from '../../../initializers'
+import { AccountModel } from '../../../models/account/account'
+import { ActorModel } from '../../../models/activitypub/actor'
+import { VideoModel } from '../../../models/video/video'
+import { VideoChannelModel } from '../../../models/video/video-channel'
+import { VideoCommentModel } from '../../../models/video/video-comment'
+import { forwardVideoRelatedActivity } from '../send/utils'
+import { VideoPlaylistModel } from '../../../models/video/video-playlist'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
+
+async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
+ const { activity, byActor } = options
+
+ const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id
+
+ if (activity.actor === objectUrl) {
+ // We need more attributes (all the account and channel)
+ const byActorFull = await ActorModel.loadByUrlAndPopulateAccountAndChannel(byActor.url)
+
+ if (byActorFull.type === 'Person') {
+ if (!byActorFull.Account) throw new Error('Actor ' + byActorFull.url + ' is a person but we cannot find it in database.')
+
+ byActorFull.Account.Actor = await byActorFull.Account.$get('Actor') as ActorModel
+ return retryTransactionWrapper(processDeleteAccount, byActorFull.Account)
+ } else if (byActorFull.type === 'Group') {
+ if (!byActorFull.VideoChannel) throw new Error('Actor ' + byActorFull.url + ' is a group but we cannot find it in database.')
+
+ byActorFull.VideoChannel.Actor = await byActorFull.VideoChannel.$get('Actor') as ActorModel
+ return retryTransactionWrapper(processDeleteVideoChannel, byActorFull.VideoChannel)
+ }
+ }