aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-delete.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/process/process-delete.ts')
-rw-r--r--server/lib/activitypub/process/process-delete.ts35
1 files changed, 17 insertions, 18 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts
index 41cdc236d..8f280d37f 100644
--- a/server/lib/activitypub/process/process-delete.ts
+++ b/server/lib/activitypub/process/process-delete.ts
@@ -1,10 +1,9 @@
1import { ActivityDelete } from '../../../../shared/models/activitypub/activity' 1import { ActivityDelete } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { logger, retryTransactionWrapper } from '../../../helpers'
3import { logger } from '../../../helpers/logger' 3import { sequelizeTypescript } from '../../../initializers'
4import { database as db } from '../../../initializers' 4import { AccountModel } from '../../../models/account/account'
5import { AccountInstance } from '../../../models/account/account-interface' 5import { VideoModel } from '../../../models/video/video'
6import { VideoChannelInstance } from '../../../models/video/video-channel-interface' 6import { VideoChannelModel } from '../../../models/video/video-channel'
7import { VideoInstance } from '../../../models/video/video-interface'
8import { getOrCreateAccountAndServer } from '../account' 7import { getOrCreateAccountAndServer } from '../account'
9 8
10async function processDeleteActivity (activity: ActivityDelete) { 9async function processDeleteActivity (activity: ActivityDelete) {
@@ -15,14 +14,14 @@ async function processDeleteActivity (activity: ActivityDelete) {
15 } 14 }
16 15
17 { 16 {
18 let videoObject = await db.Video.loadByUrlAndPopulateAccount(activity.id) 17 let videoObject = await VideoModel.loadByUrlAndPopulateAccount(activity.id)
19 if (videoObject !== undefined) { 18 if (videoObject !== undefined) {
20 return processDeleteVideo(account, videoObject) 19 return processDeleteVideo(account, videoObject)
21 } 20 }
22 } 21 }
23 22
24 { 23 {
25 let videoChannelObject = await db.VideoChannel.loadByUrl(activity.id) 24 let videoChannelObject = await VideoChannelModel.loadByUrl(activity.id)
26 if (videoChannelObject !== undefined) { 25 if (videoChannelObject !== undefined) {
27 return processDeleteVideoChannel(account, videoChannelObject) 26 return processDeleteVideoChannel(account, videoChannelObject)
28 } 27 }
@@ -39,7 +38,7 @@ export {
39 38
40// --------------------------------------------------------------------------- 39// ---------------------------------------------------------------------------
41 40
42async function processDeleteVideo (account: AccountInstance, videoToDelete: VideoInstance) { 41async function processDeleteVideo (account: AccountModel, videoToDelete: VideoModel) {
43 const options = { 42 const options = {
44 arguments: [ account, videoToDelete ], 43 arguments: [ account, videoToDelete ],
45 errorMessage: 'Cannot remove the remote video with many retries.' 44 errorMessage: 'Cannot remove the remote video with many retries.'
@@ -48,10 +47,10 @@ async function processDeleteVideo (account: AccountInstance, videoToDelete: Vide
48 await retryTransactionWrapper(deleteRemoteVideo, options) 47 await retryTransactionWrapper(deleteRemoteVideo, options)
49} 48}
50 49
51async function deleteRemoteVideo (account: AccountInstance, videoToDelete: VideoInstance) { 50async function deleteRemoteVideo (account: AccountModel, videoToDelete: VideoModel) {
52 logger.debug('Removing remote video "%s".', videoToDelete.uuid) 51 logger.debug('Removing remote video "%s".', videoToDelete.uuid)
53 52
54 await db.sequelize.transaction(async t => { 53 await sequelizeTypescript.transaction(async t => {
55 if (videoToDelete.VideoChannel.Account.id !== account.id) { 54 if (videoToDelete.VideoChannel.Account.id !== account.id) {
56 throw new Error('Account ' + account.url + ' does not own video channel ' + videoToDelete.VideoChannel.url) 55 throw new Error('Account ' + account.url + ' does not own video channel ' + videoToDelete.VideoChannel.url)
57 } 56 }
@@ -62,7 +61,7 @@ async function deleteRemoteVideo (account: AccountInstance, videoToDelete: Video
62 logger.info('Remote video with uuid %s removed.', videoToDelete.uuid) 61 logger.info('Remote video with uuid %s removed.', videoToDelete.uuid)
63} 62}
64 63
65async function processDeleteVideoChannel (account: AccountInstance, videoChannelToRemove: VideoChannelInstance) { 64async function processDeleteVideoChannel (account: AccountModel, videoChannelToRemove: VideoChannelModel) {
66 const options = { 65 const options = {
67 arguments: [ account, videoChannelToRemove ], 66 arguments: [ account, videoChannelToRemove ],
68 errorMessage: 'Cannot remove the remote video channel with many retries.' 67 errorMessage: 'Cannot remove the remote video channel with many retries.'
@@ -71,10 +70,10 @@ async function processDeleteVideoChannel (account: AccountInstance, videoChannel
71 await retryTransactionWrapper(deleteRemoteVideoChannel, options) 70 await retryTransactionWrapper(deleteRemoteVideoChannel, options)
72} 71}
73 72
74async function deleteRemoteVideoChannel (account: AccountInstance, videoChannelToRemove: VideoChannelInstance) { 73async function deleteRemoteVideoChannel (account: AccountModel, videoChannelToRemove: VideoChannelModel) {
75 logger.debug('Removing remote video channel "%s".', videoChannelToRemove.uuid) 74 logger.debug('Removing remote video channel "%s".', videoChannelToRemove.uuid)
76 75
77 await db.sequelize.transaction(async t => { 76 await sequelizeTypescript.transaction(async t => {
78 if (videoChannelToRemove.Account.id !== account.id) { 77 if (videoChannelToRemove.Account.id !== account.id) {
79 throw new Error('Account ' + account.url + ' does not own video channel ' + videoChannelToRemove.url) 78 throw new Error('Account ' + account.url + ' does not own video channel ' + videoChannelToRemove.url)
80 } 79 }
@@ -85,7 +84,7 @@ async function deleteRemoteVideoChannel (account: AccountInstance, videoChannelT
85 logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.uuid) 84 logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.uuid)
86} 85}
87 86
88async function processDeleteAccount (accountToRemove: AccountInstance) { 87async function processDeleteAccount (accountToRemove: AccountModel) {
89 const options = { 88 const options = {
90 arguments: [ accountToRemove ], 89 arguments: [ accountToRemove ],
91 errorMessage: 'Cannot remove the remote account with many retries.' 90 errorMessage: 'Cannot remove the remote account with many retries.'
@@ -94,10 +93,10 @@ async function processDeleteAccount (accountToRemove: AccountInstance) {
94 await retryTransactionWrapper(deleteRemoteAccount, options) 93 await retryTransactionWrapper(deleteRemoteAccount, options)
95} 94}
96 95
97async function deleteRemoteAccount (accountToRemove: AccountInstance) { 96async function deleteRemoteAccount (accountToRemove: AccountModel) {
98 logger.debug('Removing remote account "%s".', accountToRemove.uuid) 97 logger.debug('Removing remote account "%s".', accountToRemove.uuid)
99 98
100 await db.sequelize.transaction(async t => { 99 await sequelizeTypescript.transaction(async t => {
101 await accountToRemove.destroy({ transaction: t }) 100 await accountToRemove.destroy({ transaction: t })
102 }) 101 })
103 102