import { VideoCommentModel } from '../../models/video/video-comment'
import { VideoShareModel } from '../../models/video/video-share'
-function getVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]) {
+function getRemoteVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]): ActivityAudience {
return {
to: [ video.VideoChannel.Account.Actor.url ],
cc: actorsInvolvedInVideo.map(a => a.followersUrl)
threadParentComments: VideoCommentModel[],
actorsInvolvedInVideo: ActorModel[],
isOrigin = false
-) {
+): ActivityAudience {
const to = [ ACTIVITY_PUB.PUBLIC ]
- const cc = [ ]
+ const cc: string[] = []
// Owner of the video we comment
if (isOrigin === false) {
}
}
-function getObjectFollowersAudience (actorsInvolvedInObject: ActorModel[]) {
+function getAudienceFromFollowersOf (actorsInvolvedInObject: ActorModel[]): ActivityAudience {
return {
to: [ ACTIVITY_PUB.PUBLIC ].concat(actorsInvolvedInObject.map(a => a.followersUrl)),
cc: []
async function getActorsInvolvedInVideo (video: VideoModel, t: Transaction) {
const actors = await VideoShareModel.loadActorsByShare(video.id, t)
- actors.push(video.VideoChannel.Account.Actor)
+
+ const videoActor = video.VideoChannel && video.VideoChannel.Account
+ ? video.VideoChannel.Account.Actor
+ : await ActorModel.loadAccountActorByVideoId(video.id, t)
+
+ actors.push(videoActor)
return actors
}
-async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = true) {
+function getAudience (actorSender: ActorModel, isPublic = true) {
return buildAudience([ actorSender.followersUrl ], isPublic)
}
-function buildAudience (followerInboxUrls: string[], isPublic = true) {
- // Thanks Mastodon: https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/tag_manager.rb#L47
- let to = []
- let cc = []
+function buildAudience (followerUrls: string[], isPublic = true) {
+ let to: string[] = []
+ let cc: string[] = []
if (isPublic) {
to = [ ACTIVITY_PUB.PUBLIC ]
- cc = followerInboxUrls
+ cc = followerUrls
} else { // Unlisted
- to = [ ]
- cc = [ ]
+ to = []
+ cc = []
}
return { to, cc }
}
-function audiencify <T> (object: T, audience: ActivityAudience) {
+function audiencify<T> (object: T, audience: ActivityAudience) {
return Object.assign(object, audience)
}
export {
buildAudience,
getAudience,
- getVideoAudience,
+ getRemoteVideoAudience,
getActorsInvolvedInVideo,
- getObjectFollowersAudience,
+ getAudienceFromFollowersOf,
audiencify,
getVideoCommentAudience
}