diff options
Diffstat (limited to 'server/lib/activitypub/process/process-delete.ts')
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 155d2ffcc..76f07fd8a 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -8,6 +8,7 @@ import { VideoModel } from '../../../models/video/video' | |||
8 | import { VideoChannelModel } from '../../../models/video/video-channel' | 8 | import { VideoChannelModel } from '../../../models/video/video-channel' |
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | 9 | import { VideoCommentModel } from '../../../models/video/video-comment' |
10 | import { forwardVideoRelatedActivity } from '../send/utils' | 10 | import { forwardVideoRelatedActivity } from '../send/utils' |
11 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
11 | 12 | ||
12 | async function processDeleteActivity (activity: ActivityDelete, byActor: ActorModel) { | 13 | async function processDeleteActivity (activity: ActivityDelete, byActor: ActorModel) { |
13 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id | 14 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id |
@@ -45,6 +46,15 @@ async function processDeleteActivity (activity: ActivityDelete, byActor: ActorMo | |||
45 | } | 46 | } |
46 | } | 47 | } |
47 | 48 | ||
49 | { | ||
50 | const videoPlaylist = await VideoPlaylistModel.loadByUrlAndPopulateAccount(objectUrl) | ||
51 | if (videoPlaylist) { | ||
52 | if (videoPlaylist.isOwned()) throw new Error(`Remote instance cannot delete owned playlist ${videoPlaylist.url}.`) | ||
53 | |||
54 | return retryTransactionWrapper(processDeleteVideoPlaylist, byActor, videoPlaylist) | ||
55 | } | ||
56 | } | ||
57 | |||
48 | return undefined | 58 | return undefined |
49 | } | 59 | } |
50 | 60 | ||
@@ -70,6 +80,20 @@ async function processDeleteVideo (actor: ActorModel, videoToDelete: VideoModel) | |||
70 | logger.info('Remote video with uuid %s removed.', videoToDelete.uuid) | 80 | logger.info('Remote video with uuid %s removed.', videoToDelete.uuid) |
71 | } | 81 | } |
72 | 82 | ||
83 | async function processDeleteVideoPlaylist (actor: ActorModel, playlistToDelete: VideoPlaylistModel) { | ||
84 | logger.debug('Removing remote video playlist "%s".', playlistToDelete.uuid) | ||
85 | |||
86 | await sequelizeTypescript.transaction(async t => { | ||
87 | if (playlistToDelete.OwnerAccount.Actor.id !== actor.id) { | ||
88 | throw new Error('Account ' + actor.url + ' does not own video playlist ' + playlistToDelete.url) | ||
89 | } | ||
90 | |||
91 | await playlistToDelete.destroy({ transaction: t }) | ||
92 | }) | ||
93 | |||
94 | logger.info('Remote video playlist with uuid %s removed.', playlistToDelete.uuid) | ||
95 | } | ||
96 | |||
73 | async function processDeleteAccount (accountToRemove: AccountModel) { | 97 | async function processDeleteAccount (accountToRemove: AccountModel) { |
74 | logger.debug('Removing remote account "%s".', accountToRemove.Actor.uuid) | 98 | logger.debug('Removing remote account "%s".', accountToRemove.Actor.uuid) |
75 | 99 | ||