]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-add.ts
Fix bad to/cc when undo dislike
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-add.ts
index 98280b9f05fe490a9bcb1abdc1dd5c8cbc853ed0..e6bf63eb245c68fa2b52fffe29fa314012e738e7 100644 (file)
@@ -11,7 +11,7 @@ import { VideoInstance } from '../../../models/video/video-interface'
 import { getOrCreateAccountAndServer } from '../account'
 import { getOrCreateVideoChannel } from '../video-channels'
 import { generateThumbnailFromUrl } from '../videos'
-import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc'
+import { addVideoShares, videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc'
 
 async function processAddActivity (activity: ActivityAdd) {
   const activityObject = activity.object
@@ -37,12 +37,10 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function processAddVideo (
-  account: AccountInstance,
-  activity: ActivityAdd,
-  videoChannel: VideoChannelInstance,
-  videoToCreateData: VideoTorrentObject
-) {
+async function processAddVideo (account: AccountInstance,
+                                activity: ActivityAdd,
+                                videoChannel: VideoChannelInstance,
+                                videoToCreateData: VideoTorrentObject) {
   const options = {
     arguments: [ account, activity, videoChannel, videoToCreateData ],
     errorMessage: 'Cannot insert the remote video with many retries.'
@@ -59,6 +57,10 @@ async function processAddVideo (
     await createRates(videoToCreateData.dislikes.orderedItems, video, 'dislike')
   }
 
+  if (videoToCreateData.shares && Array.isArray(videoToCreateData.shares.orderedItems)) {
+    await addVideoShares(video, videoToCreateData.shares.orderedItems)
+  }
+
   return video
 }