aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-17 10:49:37 +0200
committerChocobozzz <me@florianbigard.com>2022-06-17 11:55:03 +0200
commit3396e6534592865f184ee2db32a75957c42cb887 (patch)
tree324aeab92a27f2ffd1e8a16b09f0b5509bf8f477 /server/lib
parentb9e49a45f5441fd1a2d49a10b88aaf4d425dc992 (diff)
downloadPeerTube-3396e6534592865f184ee2db32a75957c42cb887.tar.gz
PeerTube-3396e6534592865f184ee2db32a75957c42cb887.tar.zst
PeerTube-3396e6534592865f184ee2db32a75957c42cb887.zip
Optimize broadcast job creation
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/send/shared/audience-utils.ts6
-rw-r--r--server/lib/activitypub/send/shared/send-utils.ts4
-rw-r--r--server/lib/views/shared/video-viewer-counters.ts1
3 files changed, 5 insertions, 6 deletions
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'
3import { ActorModel } from '@server/models/actor/actor' 3import { ActorModel } from '@server/models/actor/actor'
4import { VideoModel } from '@server/models/video/video' 4import { VideoModel } from '@server/models/video/video'
5import { VideoShareModel } from '@server/models/video/video-share' 5import { VideoShareModel } from '@server/models/video/video-share'
6import { MActorFollowersUrl, MActorLight, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '@server/types/models' 6import { MActorFollowersUrl, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '@server/types/models'
7import { ActivityAudience } from '@shared/models' 7import { ActivityAudience } from '@shared/models'
8 8
9function getOriginVideoAudience (accountActor: MActorUrl, actorsInvolvedInVideo: MActorFollowersUrl[] = []): ActivityAudience { 9function getOriginVideoAudience (accountActor: MActorUrl, actorsInvolvedInVideo: MActorFollowersUrl[] = []): ActivityAudience {
@@ -51,13 +51,13 @@ function getAudienceFromFollowersOf (actorsInvolvedInObject: MActorFollowersUrl[
51} 51}
52 52
53async function getActorsInvolvedInVideo (video: MVideoId, t: Transaction) { 53async function getActorsInvolvedInVideo (video: MVideoId, t: Transaction) {
54 const actors: MActorLight[] = await VideoShareModel.loadActorsByShare(video.id, t) 54 const actors = await VideoShareModel.listActorIdsAndFollowerUrlsByShare(video.id, t)
55 55
56 const videoAll = video as VideoModel 56 const videoAll = video as VideoModel
57 57
58 const videoActor = videoAll.VideoChannel?.Account 58 const videoActor = videoAll.VideoChannel?.Account
59 ? videoAll.VideoChannel.Account.Actor 59 ? videoAll.VideoChannel.Account.Actor
60 : await ActorModel.loadFromAccountByVideoId(video.id, t) 60 : await ActorModel.loadAccountActorFollowerUrlByVideoId(video.id, t)
61 61
62 actors.push(videoActor) 62 actors.push(videoActor)
63 63
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
19}) { 19}) {
20 const { byActor, video, transaction, contextType } = options 20 const { byActor, video, transaction, contextType } = options
21 21
22 const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, transaction)
23
24 // Send to origin 22 // Send to origin
25 if (video.isOwned() === false) { 23 if (video.isOwned() === false) {
26 return sendVideoActivityToOrigin(activityBuilder, options) 24 return sendVideoActivityToOrigin(activityBuilder, options)
27 } 25 }
28 26
27 const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, transaction)
28
29 // Send to followers 29 // Send to followers
30 const audience = getAudienceFromFollowersOf(actorsInvolvedInVideo) 30 const audience = getAudienceFromFollowersOf(actorsInvolvedInVideo)
31 const activity = activityBuilder(audience) 31 const activity = activityBuilder(audience)
diff --git a/server/lib/views/shared/video-viewer-counters.ts b/server/lib/views/shared/video-viewer-counters.ts
index 941b62ed7..999ab7d8d 100644
--- a/server/lib/views/shared/video-viewer-counters.ts
+++ b/server/lib/views/shared/video-viewer-counters.ts
@@ -1,4 +1,3 @@
1
2import { isTestInstance } from '@server/helpers/core-utils' 1import { isTestInstance } from '@server/helpers/core-utils'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 2import { logger, loggerTagsFactory } from '@server/helpers/logger'
4import { VIEW_LIFETIME } from '@server/initializers/constants' 3import { VIEW_LIFETIME } from '@server/initializers/constants'