diff options
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 23 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 21 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-update.ts | 30 |
3 files changed, 72 insertions, 2 deletions
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index ef20e404c..bacdb97e3 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -8,6 +8,9 @@ import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unic | |||
8 | import { audiencify, getActorsInvolvedInVideo, getAudience, getAudienceFromFollowersOf, getVideoCommentAudience } from '../audience' | 8 | import { audiencify, getActorsInvolvedInVideo, getAudience, getAudienceFromFollowersOf, getVideoCommentAudience } from '../audience' |
9 | import { logger } from '../../../helpers/logger' | 9 | import { logger } from '../../../helpers/logger' |
10 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | 10 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' |
11 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
12 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
13 | import { getServerActor } from '../../../helpers/utils' | ||
11 | 14 | ||
12 | async function sendCreateVideo (video: VideoModel, t: Transaction) { | 15 | async function sendCreateVideo (video: VideoModel, t: Transaction) { |
13 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined | 16 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined |
@@ -34,6 +37,25 @@ async function sendCreateCacheFile (byActor: ActorModel, video: VideoModel, file | |||
34 | }) | 37 | }) |
35 | } | 38 | } |
36 | 39 | ||
40 | async function sendCreateVideoPlaylist (playlist: VideoPlaylistModel, t: Transaction) { | ||
41 | if (playlist.privacy === VideoPlaylistPrivacy.PRIVATE) return undefined | ||
42 | |||
43 | logger.info('Creating job to send create video playlist of %s.', playlist.url) | ||
44 | |||
45 | const byActor = playlist.OwnerAccount.Actor | ||
46 | const audience = getAudience(byActor, playlist.privacy === VideoPlaylistPrivacy.PUBLIC) | ||
47 | |||
48 | const object = await playlist.toActivityPubObject() | ||
49 | const createActivity = buildCreateActivity(playlist.url, byActor, object, audience) | ||
50 | |||
51 | const serverActor = await getServerActor() | ||
52 | const toFollowersOf = [ byActor, serverActor ] | ||
53 | |||
54 | if (playlist.VideoChannel) toFollowersOf.push(playlist.VideoChannel.Actor) | ||
55 | |||
56 | return broadcastToFollowers(createActivity, byActor, toFollowersOf, t) | ||
57 | } | ||
58 | |||
37 | async function sendCreateVideoComment (comment: VideoCommentModel, t: Transaction) { | 59 | async function sendCreateVideoComment (comment: VideoCommentModel, t: Transaction) { |
38 | logger.info('Creating job to send comment %s.', comment.url) | 60 | logger.info('Creating job to send comment %s.', comment.url) |
39 | 61 | ||
@@ -92,6 +114,7 @@ export { | |||
92 | sendCreateVideo, | 114 | sendCreateVideo, |
93 | buildCreateActivity, | 115 | buildCreateActivity, |
94 | sendCreateVideoComment, | 116 | sendCreateVideoComment, |
117 | sendCreateVideoPlaylist, | ||
95 | sendCreateCacheFile | 118 | sendCreateCacheFile |
96 | } | 119 | } |
97 | 120 | ||
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 18969433a..016811e60 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -8,6 +8,8 @@ import { getDeleteActivityPubUrl } from '../url' | |||
8 | import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' | 8 | import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' |
9 | import { audiencify, getActorsInvolvedInVideo, getVideoCommentAudience } from '../audience' | 9 | import { audiencify, getActorsInvolvedInVideo, getVideoCommentAudience } from '../audience' |
10 | import { logger } from '../../../helpers/logger' | 10 | import { logger } from '../../../helpers/logger' |
11 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
12 | import { getServerActor } from '../../../helpers/utils' | ||
11 | 13 | ||
12 | async function sendDeleteVideo (video: VideoModel, transaction: Transaction) { | 14 | async function sendDeleteVideo (video: VideoModel, transaction: Transaction) { |
13 | logger.info('Creating job to broadcast delete of video %s.', video.url) | 15 | logger.info('Creating job to broadcast delete of video %s.', video.url) |
@@ -64,12 +66,29 @@ async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Trans | |||
64 | return unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl) | 66 | return unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl) |
65 | } | 67 | } |
66 | 68 | ||
69 | async function sendDeleteVideoPlaylist (videoPlaylist: VideoPlaylistModel, t: Transaction) { | ||
70 | logger.info('Creating job to send delete of playlist %s.', videoPlaylist.url) | ||
71 | |||
72 | const byActor = videoPlaylist.OwnerAccount.Actor | ||
73 | |||
74 | const url = getDeleteActivityPubUrl(videoPlaylist.url) | ||
75 | const activity = buildDeleteActivity(url, videoPlaylist.url, byActor) | ||
76 | |||
77 | const serverActor = await getServerActor() | ||
78 | const toFollowersOf = [ byActor, serverActor ] | ||
79 | |||
80 | if (videoPlaylist.VideoChannel) toFollowersOf.push(videoPlaylist.VideoChannel.Actor) | ||
81 | |||
82 | return broadcastToFollowers(activity, byActor, toFollowersOf, t) | ||
83 | } | ||
84 | |||
67 | // --------------------------------------------------------------------------- | 85 | // --------------------------------------------------------------------------- |
68 | 86 | ||
69 | export { | 87 | export { |
70 | sendDeleteVideo, | 88 | sendDeleteVideo, |
71 | sendDeleteActor, | 89 | sendDeleteActor, |
72 | sendDeleteVideoComment | 90 | sendDeleteVideoComment, |
91 | sendDeleteVideoPlaylist | ||
73 | } | 92 | } |
74 | 93 | ||
75 | // --------------------------------------------------------------------------- | 94 | // --------------------------------------------------------------------------- |
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index 839f66470..3eb2704fd 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts | |||
@@ -12,8 +12,13 @@ import { audiencify, getActorsInvolvedInVideo, getAudience } from '../audience' | |||
12 | import { logger } from '../../../helpers/logger' | 12 | import { logger } from '../../../helpers/logger' |
13 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 13 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
14 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | 14 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' |
15 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
16 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
17 | import { getServerActor } from '../../../helpers/utils' | ||
15 | 18 | ||
16 | async function sendUpdateVideo (video: VideoModel, t: Transaction, overrodeByActor?: ActorModel) { | 19 | async function sendUpdateVideo (video: VideoModel, t: Transaction, overrodeByActor?: ActorModel) { |
20 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined | ||
21 | |||
17 | logger.info('Creating job to update video %s.', video.url) | 22 | logger.info('Creating job to update video %s.', video.url) |
18 | 23 | ||
19 | const byActor = overrodeByActor ? overrodeByActor : video.VideoChannel.Account.Actor | 24 | const byActor = overrodeByActor ? overrodeByActor : video.VideoChannel.Account.Actor |
@@ -73,12 +78,35 @@ async function sendUpdateCacheFile (byActor: ActorModel, redundancyModel: VideoR | |||
73 | return sendVideoRelatedActivity(activityBuilder, { byActor, video }) | 78 | return sendVideoRelatedActivity(activityBuilder, { byActor, video }) |
74 | } | 79 | } |
75 | 80 | ||
81 | async function sendUpdateVideoPlaylist (videoPlaylist: VideoPlaylistModel, t: Transaction) { | ||
82 | if (videoPlaylist.privacy === VideoPlaylistPrivacy.PRIVATE) return undefined | ||
83 | |||
84 | const byActor = videoPlaylist.OwnerAccount.Actor | ||
85 | |||
86 | logger.info('Creating job to update video playlist %s.', videoPlaylist.url) | ||
87 | |||
88 | const url = getUpdateActivityPubUrl(videoPlaylist.url, videoPlaylist.updatedAt.toISOString()) | ||
89 | |||
90 | const object = await videoPlaylist.toActivityPubObject() | ||
91 | const audience = getAudience(byActor, videoPlaylist.privacy === VideoPlaylistPrivacy.PUBLIC) | ||
92 | |||
93 | const updateActivity = buildUpdateActivity(url, byActor, object, audience) | ||
94 | |||
95 | const serverActor = await getServerActor() | ||
96 | const toFollowersOf = [ byActor, serverActor ] | ||
97 | |||
98 | if (videoPlaylist.VideoChannel) toFollowersOf.push(videoPlaylist.VideoChannel.Actor) | ||
99 | |||
100 | return broadcastToFollowers(updateActivity, byActor, toFollowersOf, t) | ||
101 | } | ||
102 | |||
76 | // --------------------------------------------------------------------------- | 103 | // --------------------------------------------------------------------------- |
77 | 104 | ||
78 | export { | 105 | export { |
79 | sendUpdateActor, | 106 | sendUpdateActor, |
80 | sendUpdateVideo, | 107 | sendUpdateVideo, |
81 | sendUpdateCacheFile | 108 | sendUpdateCacheFile, |
109 | sendUpdateVideoPlaylist | ||
82 | } | 110 | } |
83 | 111 | ||
84 | // --------------------------------------------------------------------------- | 112 | // --------------------------------------------------------------------------- |