From: Chocobozzz Date: Thu, 26 Oct 2017 12:05:20 +0000 (+0200) Subject: Fix integrity issues with after destroy hook X-Git-Tag: v0.0.1-alpha~262 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=911238e343e1cccae349ff9c44bcffadb96fa393;p=oweals%2Fpeertube.git Fix integrity issues with after destroy hook --- diff --git a/server/lib/friends.ts b/server/lib/friends.ts index a33432dc1..55cbb55b9 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts @@ -86,7 +86,7 @@ function updateVideoToFriends (videoData: RemoteVideoUpdateData, transaction: Se return createRequest(options) } -function removeVideoToFriends (videoParams: RemoteVideoRemoveData, transaction: Sequelize.Transaction) { +function removeVideoToFriends (videoParams: RemoteVideoRemoveData, transaction?: Sequelize.Transaction) { const options = { type: ENDPOINT_ACTIONS.REMOVE_VIDEO, endpoint: REQUEST_ENDPOINTS.VIDEOS, @@ -106,7 +106,7 @@ function addVideoAuthorToFriends (authorData: RemoteVideoAuthorCreateData, trans return createRequest(options) } -function removeVideoAuthorToFriends (authorData: RemoteVideoAuthorRemoveData, transaction: Sequelize.Transaction) { +function removeVideoAuthorToFriends (authorData: RemoteVideoAuthorRemoveData, transaction?: Sequelize.Transaction) { const options = { type: ENDPOINT_ACTIONS.REMOVE_AUTHOR, endpoint: REQUEST_ENDPOINTS.VIDEOS, @@ -136,7 +136,7 @@ function updateVideoChannelToFriends (videoChannelData: RemoteVideoChannelUpdate return createRequest(options) } -function removeVideoChannelToFriends (videoChannelParams: RemoteVideoChannelRemoveData, transaction: Sequelize.Transaction) { +function removeVideoChannelToFriends (videoChannelParams: RemoteVideoChannelRemoveData, transaction?: Sequelize.Transaction) { const options = { type: ENDPOINT_ACTIONS.REMOVE_CHANNEL, endpoint: REQUEST_ENDPOINTS.VIDEOS, diff --git a/server/models/video/author.ts b/server/models/video/author.ts index 6f27ea7bd..43f84c3ea 100644 --- a/server/models/video/author.ts +++ b/server/models/video/author.ts @@ -107,13 +107,13 @@ function associate (models) { }) } -function afterDestroy (author: AuthorInstance, options: { transaction: Sequelize.Transaction }) { +function afterDestroy (author: AuthorInstance) { if (author.isOwned()) { const removeVideoAuthorToFriendsParams = { uuid: author.uuid } - return removeVideoAuthorToFriends(removeVideoAuthorToFriendsParams, options.transaction) + return removeVideoAuthorToFriends(removeVideoAuthorToFriendsParams) } return undefined diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index e469383e9..46c2db63f 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -178,13 +178,13 @@ function associate (models) { }) } -function afterDestroy (videoChannel: VideoChannelInstance, options: { transaction: Sequelize.Transaction }) { +function afterDestroy (videoChannel: VideoChannelInstance) { if (videoChannel.isOwned()) { const removeVideoChannelToFriendsParams = { uuid: videoChannel.uuid } - return removeVideoChannelToFriends(removeVideoChannelToFriendsParams, options.transaction) + return removeVideoChannelToFriends(removeVideoChannelToFriendsParams) } return undefined diff --git a/server/models/video/video.ts b/server/models/video/video.ts index ec14939c2..6c0db59f3 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -317,7 +317,7 @@ function associate (models) { }) } -function afterDestroy (video: VideoInstance, options: { transaction: Sequelize.Transaction }) { +function afterDestroy (video: VideoInstance) { const tasks = [] tasks.push( @@ -331,7 +331,7 @@ function afterDestroy (video: VideoInstance, options: { transaction: Sequelize.T tasks.push( video.removePreview(), - removeVideoToFriends(removeVideoToFriendsParams, options.transaction) + removeVideoToFriends(removeVideoToFriendsParams) ) // Remove physical files and torrents