import { ACTIVITY_PUB } from '../../initializers/constants'
import { ActorModel } from '../../models/activitypub/actor'
import { VideoModel } from '../../models/video/video'
-import { VideoCommentModel } from '../../models/video/video-comment'
import { VideoShareModel } from '../../models/video/video-share'
+import { MActorFollowersUrl, MActorLight, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '../../typings/models'
-function getRemoteVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]): ActivityAudience {
+function getRemoteVideoAudience (accountActor: MActorUrl, actorsInvolvedInVideo: MActorFollowersUrl[]): ActivityAudience {
return {
- to: [ video.VideoChannel.Account.Actor.url ],
+ to: [ accountActor.url ],
cc: actorsInvolvedInVideo.map(a => a.followersUrl)
}
}
function getVideoCommentAudience (
- videoComment: VideoCommentModel,
- threadParentComments: VideoCommentModel[],
- actorsInvolvedInVideo: ActorModel[],
+ videoComment: MCommentOwnerVideo,
+ threadParentComments: MCommentOwner[],
+ actorsInvolvedInVideo: MActorFollowersUrl[],
isOrigin = false
): ActivityAudience {
const to = [ ACTIVITY_PUB.PUBLIC ]
// Send to actors we reply to
for (const parentComment of threadParentComments) {
+ if (parentComment.isDeleted()) continue
+
cc.push(parentComment.Account.Actor.url)
}
}
}
-function getAudienceFromFollowersOf (actorsInvolvedInObject: ActorModel[]): ActivityAudience {
+function getAudienceFromFollowersOf (actorsInvolvedInObject: MActorFollowersUrl[]): 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)
+async function getActorsInvolvedInVideo (video: MVideoId, t: Transaction) {
+ const actors: MActorLight[] = await VideoShareModel.loadActorsByShare(video.id, t)
+
+ const videoAll = video as VideoModel
- const videoActor = video.VideoChannel && video.VideoChannel.Account
- ? video.VideoChannel.Account.Actor
- : await ActorModel.loadAccountActorByVideoId(video.id, t)
+ const videoActor = videoAll.VideoChannel && videoAll.VideoChannel.Account
+ ? videoAll.VideoChannel.Account.Actor
+ : await ActorModel.loadFromAccountByVideoId(video.id, t)
actors.push(videoActor)
return actors
}
-function getAudience (actorSender: ActorModel, isPublic = true) {
+function getAudience (actorSender: MActorFollowersUrl, isPublic = true) {
return buildAudience([ actorSender.followersUrl ], isPublic)
}