aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-delete.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-05 10:58:44 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commitdf0b219d36bf6852cdf2a7ad09ed4a41c6bccefa (patch)
treec4984e854f5dc18e5c27afd73b843bd52c143034 /server/lib/activitypub/process/process-delete.ts
parent07b1a18aa678d260009a93e36606c5c5f585723d (diff)
downloadPeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.tar.gz
PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.tar.zst
PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.zip
Add playlist rest tests
Diffstat (limited to 'server/lib/activitypub/process/process-delete.ts')
-rw-r--r--server/lib/activitypub/process/process-delete.ts24
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'
8import { VideoChannelModel } from '../../../models/video/video-channel' 8import { VideoChannelModel } from '../../../models/video/video-channel'
9import { VideoCommentModel } from '../../../models/video/video-comment' 9import { VideoCommentModel } from '../../../models/video/video-comment'
10import { forwardVideoRelatedActivity } from '../send/utils' 10import { forwardVideoRelatedActivity } from '../send/utils'
11import { VideoPlaylistModel } from '../../../models/video/video-playlist'
11 12
12async function processDeleteActivity (activity: ActivityDelete, byActor: ActorModel) { 13async 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
83async 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
73async function processDeleteAccount (accountToRemove: AccountModel) { 97async 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