aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/process/process-view.ts19
1 files changed, 14 insertions, 5 deletions
diff --git a/server/lib/activitypub/process/process-view.ts b/server/lib/activitypub/process/process-view.ts
index cc26180af..efceb21a2 100644
--- a/server/lib/activitypub/process/process-view.ts
+++ b/server/lib/activitypub/process/process-view.ts
@@ -4,6 +4,7 @@ import { Redis } from '../../redis'
4import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub' 4import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub'
5import { APProcessorOptions } from '../../../types/activitypub-processor.model' 5import { APProcessorOptions } from '../../../types/activitypub-processor.model'
6import { MActorSignature } from '../../../types/models' 6import { MActorSignature } from '../../../types/models'
7import { LiveManager } from '@server/lib/live-manager'
7 8
8async function processViewActivity (options: APProcessorOptions<ActivityCreate | ActivityView>) { 9async function processViewActivity (options: APProcessorOptions<ActivityCreate | ActivityView>) {
9 const { activity, byActor } = options 10 const { activity, byActor } = options
@@ -19,19 +20,27 @@ export {
19// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
20 21
21async function processCreateView (activity: ActivityView | ActivityCreate, byActor: MActorSignature) { 22async function processCreateView (activity: ActivityView | ActivityCreate, byActor: MActorSignature) {
22 const videoObject = activity.type === 'View' ? activity.object : (activity.object as ViewObject).object 23 const videoObject = activity.type === 'View'
24 ? activity.object
25 : (activity.object as ViewObject).object
23 26
24 const options = { 27 const options = {
25 videoObject, 28 videoObject,
26 fetchType: 'only-immutable-attributes' as 'only-immutable-attributes', 29 fetchType: 'only-video' as 'only-video',
27 allowRefresh: false as false 30 allowRefresh: false as false
28 } 31 }
29 const { video } = await getOrCreateVideoAndAccountAndChannel(options) 32 const { video } = await getOrCreateVideoAndAccountAndChannel(options)
30 33
31 await Redis.Instance.addVideoView(video.id)
32
33 if (video.isOwned()) { 34 if (video.isOwned()) {
34 // Don't resend the activity to the sender 35 // Our live manager will increment the counter and send the view to followers
36 if (video.isLive) {
37 LiveManager.Instance.addViewTo(video.id)
38 return
39 }
40
41 await Redis.Instance.addVideoView(video.id)
42
43 // Forward the view but don't resend the activity to the sender
35 const exceptions = [ byActor ] 44 const exceptions = [ byActor ]
36 await forwardVideoRelatedActivity(activity, undefined, exceptions, video) 45 await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
37 } 46 }