]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-create.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-create.ts
index 5d87634952cc638c824efd462cfe37d3474b51bd..7c3a6bdd0a419a39b04f847e12d2340854151d23 100644 (file)
@@ -6,6 +6,7 @@ import { VideoCommentModel } from '../../../models/video/video-comment'
 import {
   MActorLight,
   MCommentOwnerVideo,
+  MLocalVideoViewerWithWatchSections,
   MVideoAccountLight,
   MVideoAP,
   MVideoPlaylistFull,
@@ -19,6 +20,7 @@ import {
   getActorsInvolvedInVideo,
   getAudienceFromFollowersOf,
   getVideoCommentAudience,
+  sendVideoActivityToOrigin,
   sendVideoRelatedActivity,
   unicastTo
 } from './shared'
@@ -61,6 +63,18 @@ async function sendCreateCacheFile (
   })
 }
 
+async function sendCreateWatchAction (stats: MLocalVideoViewerWithWatchSections, transaction: Transaction) {
+  logger.info('Creating job to send create watch action %s.', stats.url, lTags(stats.uuid))
+
+  const byActor = await getServerActor()
+
+  const activityBuilder = (audience: ActivityAudience) => {
+    return buildCreateActivity(stats.url, byActor, stats.toActivityPubObject(), audience)
+  }
+
+  return sendVideoActivityToOrigin(activityBuilder, { byActor, video: stats.Video, transaction, contextType: 'WatchAction' })
+}
+
 async function sendCreateVideoPlaylist (playlist: MVideoPlaylistFull, transaction: Transaction) {
   if (playlist.privacy === VideoPlaylistPrivacy.PRIVATE) return undefined
 
@@ -175,7 +189,8 @@ export {
   buildCreateActivity,
   sendCreateVideoComment,
   sendCreateVideoPlaylist,
-  sendCreateCacheFile
+  sendCreateCacheFile,
+  sendCreateWatchAction
 }
 
 // ---------------------------------------------------------------------------