aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-19 11:41:21 +0200
committerChocobozzz <me@florianbigard.com>2018-09-19 11:41:30 +0200
commitd4defe07d26013a75577b30608841fe3f8334308 (patch)
treeca45a396884c57046cc7f158ee0d38036e49c7cb /server/lib/activitypub/process
parent4157cdb13748cb6e8ce7081d062a8778554cc5a7 (diff)
downloadPeerTube-d4defe07d26013a75577b30608841fe3f8334308.tar.gz
PeerTube-d4defe07d26013a75577b30608841fe3f8334308.tar.zst
PeerTube-d4defe07d26013a75577b30608841fe3f8334308.zip
Optimize video view AP processing
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r--server/lib/activitypub/process/process-create.ts10
-rw-r--r--server/lib/activitypub/process/process-update.ts10
2 files changed, 16 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 99841da14..559a0c23c 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -86,10 +86,14 @@ async function processCreateDislike (byActor: ActorModel, activity: ActivityCrea
86async function processCreateView (byActor: ActorModel, activity: ActivityCreate) { 86async function processCreateView (byActor: ActorModel, activity: ActivityCreate) {
87 const view = activity.object as ViewObject 87 const view = activity.object as ViewObject
88 88
89 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: view.object }) 89 const options = {
90 videoObject: view.object,
91 fetchType: 'only-video' as 'only-video'
92 }
93 const { video } = await getOrCreateVideoAndAccountAndChannel(options)
90 94
91 const actor = await ActorModel.loadByUrl(view.actor) 95 const actorExists = await ActorModel.isActorUrlExist(view.actor)
92 if (!actor) throw new Error('Unknown actor ' + view.actor) 96 if (actorExists === false) throw new Error('Unknown actor ' + view.actor)
93 97
94 await Redis.Instance.addVideoView(video.id) 98 await Redis.Instance.addVideoView(video.id)
95 99
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 935da5a54..0bceb370e 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -51,7 +51,15 @@ async function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate)
51 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id }) 51 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id })
52 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject) 52 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
53 53
54 return updateVideoFromAP(video, videoObject, actor.Account, channelActor.VideoChannel, activity.to) 54 const updateOptions = {
55 video,
56 videoObject,
57 account: actor.Account,
58 channel: channelActor.VideoChannel,
59 updateViews: true,
60 overrideTo: activity.to
61 }
62 return updateVideoFromAP(updateOptions)
55} 63}
56 64
57async function processUpdateCacheFile (byActor: ActorModel, activity: ActivityUpdate) { 65async function processUpdateCacheFile (byActor: ActorModel, activity: ActivityUpdate) {