]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix integrity issues with after destroy hook
authorChocobozzz <florian.bigard@gmail.com>
Thu, 26 Oct 2017 12:05:20 +0000 (14:05 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 26 Oct 2017 12:05:20 +0000 (14:05 +0200)
server/lib/friends.ts
server/models/video/author.ts
server/models/video/video-channel.ts
server/models/video/video.ts

index a33432dc19bd8a7bddef630c8cd5f6fa84b2af7c..55cbb55b9f1e1199ca7a977e56a14411f678a5a0 100644 (file)
@@ -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,
index 6f27ea7bde223eaa389990b9e2bd5e7428c71934..43f84c3eada0a8c70d929af0c8efa3873647f504 100644 (file)
@@ -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
index e469383e98a0a25df7000022e6f347aca48e5d36..46c2db63fa56399e0f7ed7c3992f0876253d8fdc 100644 (file)
@@ -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
index ec14939c2618f14a6dfed8d2a00867f476f07de7..6c0db59f322ae0160ff6435fc300dfe3a4e899bd 100644 (file)
@@ -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