]>
Commit | Line | Data |
---|---|---|
b2111066 | 1 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' |
51353d9a | 2 | import { ActivityView } from '../../../../shared/models/activitypub' |
26d6bf65 C |
3 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' |
4 | import { MActorSignature } from '../../../types/models' | |
57e4e1c1 | 5 | import { forwardVideoRelatedActivity } from '../send/shared/send-utils' |
51353d9a | 6 | import { getOrCreateAPVideo } from '../videos' |
848f499d | 7 | |
51353d9a | 8 | async function processViewActivity (options: APProcessorOptions<ActivityView>) { |
1198edf4 | 9 | const { activity, byActor } = options |
51353d9a | 10 | |
848f499d C |
11 | return processCreateView(activity, byActor) |
12 | } | |
13 | ||
14 | // --------------------------------------------------------------------------- | |
15 | ||
16 | export { | |
17 | processViewActivity | |
18 | } | |
19 | ||
20 | // --------------------------------------------------------------------------- | |
21 | ||
51353d9a C |
22 | async function processCreateView (activity: ActivityView, byActor: MActorSignature) { |
23 | const videoObject = activity.object | |
848f499d | 24 | |
28dfb44b | 25 | const { video } = await getOrCreateAPVideo({ |
453e83ea | 26 | videoObject, |
28dfb44b C |
27 | fetchType: 'only-video', |
28 | allowRefresh: false | |
29 | }) | |
848f499d | 30 | |
51353d9a C |
31 | const viewerExpires = activity.expires |
32 | ? new Date(activity.expires) | |
33 | : undefined | |
c655c9ef | 34 | |
ac907dc7 | 35 | await VideoViewsManager.Instance.processRemoteView({ video, viewerId: activity.id, viewerExpires }) |
e4bf7856 | 36 | |
51353d9a | 37 | if (video.isOwned()) { |
e4bf7856 | 38 | // Forward the view but don't resend the activity to the sender |
848f499d C |
39 | const exceptions = [ byActor ] |
40 | await forwardVideoRelatedActivity(activity, undefined, exceptions, video) | |
41 | } | |
42 | } |