aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/misc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send/misc.ts')
-rw-r--r--server/lib/activitypub/send/misc.ts38
1 files changed, 34 insertions, 4 deletions
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts
index 05f327b29..4aa514c15 100644
--- a/server/lib/activitypub/send/misc.ts
+++ b/server/lib/activitypub/send/misc.ts
@@ -5,6 +5,7 @@ import { ACTIVITY_PUB } from '../../../initializers'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 6import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
7import { VideoModel } from '../../../models/video/video' 7import { VideoModel } from '../../../models/video/video'
8import { VideoCommentModel } from '../../../models/video/video-comment'
8import { VideoShareModel } from '../../../models/video/video-share' 9import { VideoShareModel } from '../../../models/video/video-share'
9import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../../jobs/activitypub-http-job-scheduler' 10import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../../jobs/activitypub-http-job-scheduler'
10 11
@@ -84,6 +85,34 @@ function getOriginVideoAudience (video: VideoModel, actorsInvolvedInVideo: Actor
84 } 85 }
85} 86}
86 87
88function getOriginVideoCommentAudience (
89 videoComment: VideoCommentModel,
90 threadParentComments: VideoCommentModel[],
91 actorsInvolvedInVideo: ActorModel[],
92 isOrigin = false
93) {
94 const to = [ ACTIVITY_PUB.PUBLIC ]
95 const cc = [ ]
96
97 // Owner of the video we comment
98 if (isOrigin === false) {
99 cc.push(videoComment.Video.VideoChannel.Account.Actor.url)
100 }
101
102 // Followers of the poster
103 cc.push(videoComment.Account.Actor.followersUrl)
104
105 // Send to actors we reply to
106 for (const parentComment of threadParentComments) {
107 cc.push(parentComment.Account.Actor.url)
108 }
109
110 return {
111 to,
112 cc: cc.concat(actorsInvolvedInVideo.map(a => a.followersUrl))
113 }
114}
115
87function getObjectFollowersAudience (actorsInvolvedInObject: ActorModel[]) { 116function getObjectFollowersAudience (actorsInvolvedInObject: ActorModel[]) {
88 return { 117 return {
89 to: actorsInvolvedInObject.map(a => a.followersUrl), 118 to: actorsInvolvedInObject.map(a => a.followersUrl),
@@ -92,10 +121,10 @@ function getObjectFollowersAudience (actorsInvolvedInObject: ActorModel[]) {
92} 121}
93 122
94async function getActorsInvolvedInVideo (video: VideoModel, t: Transaction) { 123async function getActorsInvolvedInVideo (video: VideoModel, t: Transaction) {
95 const actorsToForwardView = await VideoShareModel.loadActorsByShare(video.id, t) 124 const actors = await VideoShareModel.loadActorsByShare(video.id, t)
96 actorsToForwardView.push(video.VideoChannel.Account.Actor) 125 actors.push(video.VideoChannel.Account.Actor)
97 126
98 return actorsToForwardView 127 return actors
99} 128}
100 129
101async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = true) { 130async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = true) {
@@ -138,5 +167,6 @@ export {
138 getActorsInvolvedInVideo, 167 getActorsInvolvedInVideo,
139 getObjectFollowersAudience, 168 getObjectFollowersAudience,
140 forwardActivity, 169 forwardActivity,
141 audiencify 170 audiencify,
171 getOriginVideoCommentAudience
142} 172}