From 3396e6534592865f184ee2db32a75957c42cb887 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Jun 2022 10:49:37 +0200 Subject: Optimize broadcast job creation --- server/lib/activitypub/send/shared/audience-utils.ts | 6 +++--- server/lib/activitypub/send/shared/send-utils.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/send/shared/audience-utils.ts b/server/lib/activitypub/send/shared/audience-utils.ts index ba4be487c..2f6b0741d 100644 --- a/server/lib/activitypub/send/shared/audience-utils.ts +++ b/server/lib/activitypub/send/shared/audience-utils.ts @@ -3,7 +3,7 @@ import { ACTIVITY_PUB } from '@server/initializers/constants' import { ActorModel } from '@server/models/actor/actor' import { VideoModel } from '@server/models/video/video' import { VideoShareModel } from '@server/models/video/video-share' -import { MActorFollowersUrl, MActorLight, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '@server/types/models' +import { MActorFollowersUrl, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '@server/types/models' import { ActivityAudience } from '@shared/models' function getOriginVideoAudience (accountActor: MActorUrl, actorsInvolvedInVideo: MActorFollowersUrl[] = []): ActivityAudience { @@ -51,13 +51,13 @@ function getAudienceFromFollowersOf (actorsInvolvedInObject: MActorFollowersUrl[ } async function getActorsInvolvedInVideo (video: MVideoId, t: Transaction) { - const actors: MActorLight[] = await VideoShareModel.loadActorsByShare(video.id, t) + const actors = await VideoShareModel.listActorIdsAndFollowerUrlsByShare(video.id, t) const videoAll = video as VideoModel const videoActor = videoAll.VideoChannel?.Account ? videoAll.VideoChannel.Account.Actor - : await ActorModel.loadFromAccountByVideoId(video.id, t) + : await ActorModel.loadAccountActorFollowerUrlByVideoId(video.id, t) actors.push(videoActor) diff --git a/server/lib/activitypub/send/shared/send-utils.ts b/server/lib/activitypub/send/shared/send-utils.ts index dbcde91ee..72368c762 100644 --- a/server/lib/activitypub/send/shared/send-utils.ts +++ b/server/lib/activitypub/send/shared/send-utils.ts @@ -19,13 +19,13 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud }) { const { byActor, video, transaction, contextType } = options - const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, transaction) - // Send to origin if (video.isOwned() === false) { return sendVideoActivityToOrigin(activityBuilder, options) } + const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, transaction) + // Send to followers const audience = getAudienceFromFollowersOf(actorsInvolvedInVideo) const activity = activityBuilder(audience) -- cgit v1.2.3