diff options
Diffstat (limited to 'server/lib/activitypub/send/send-view.ts')
-rw-r--r-- | server/lib/activitypub/send/send-view.ts | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/server/lib/activitypub/send/send-view.ts b/server/lib/activitypub/send/send-view.ts deleted file mode 100644 index bf3451603..000000000 --- a/server/lib/activitypub/send/send-view.ts +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | import { Transaction } from 'sequelize' | ||
2 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' | ||
3 | import { MActorAudience, MActorLight, MVideoImmutable, MVideoUrl } from '@server/types/models' | ||
4 | import { ActivityAudience, ActivityView } from '@shared/models' | ||
5 | import { logger } from '../../../helpers/logger' | ||
6 | import { audiencify, getAudience } from '../audience' | ||
7 | import { getLocalVideoViewActivityPubUrl } from '../url' | ||
8 | import { sendVideoRelatedActivity } from './shared/send-utils' | ||
9 | |||
10 | type ViewType = 'view' | 'viewer' | ||
11 | |||
12 | async function sendView (options: { | ||
13 | byActor: MActorLight | ||
14 | type: ViewType | ||
15 | video: MVideoImmutable | ||
16 | viewerIdentifier: string | ||
17 | transaction?: Transaction | ||
18 | }) { | ||
19 | const { byActor, type, video, viewerIdentifier, transaction } = options | ||
20 | |||
21 | logger.info('Creating job to send %s of %s.', type, video.url) | ||
22 | |||
23 | const activityBuilder = (audience: ActivityAudience) => { | ||
24 | const url = getLocalVideoViewActivityPubUrl(byActor, video, viewerIdentifier) | ||
25 | |||
26 | return buildViewActivity({ url, byActor, video, audience, type }) | ||
27 | } | ||
28 | |||
29 | return sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction, contextType: 'View', parallelizable: true }) | ||
30 | } | ||
31 | |||
32 | // --------------------------------------------------------------------------- | ||
33 | |||
34 | export { | ||
35 | sendView | ||
36 | } | ||
37 | |||
38 | // --------------------------------------------------------------------------- | ||
39 | |||
40 | function buildViewActivity (options: { | ||
41 | url: string | ||
42 | byActor: MActorAudience | ||
43 | video: MVideoUrl | ||
44 | type: ViewType | ||
45 | audience?: ActivityAudience | ||
46 | }): ActivityView { | ||
47 | const { url, byActor, type, video, audience = getAudience(byActor) } = options | ||
48 | |||
49 | return audiencify( | ||
50 | { | ||
51 | id: url, | ||
52 | type: 'View' as 'View', | ||
53 | actor: byActor.url, | ||
54 | object: video.url, | ||
55 | |||
56 | expires: type === 'viewer' | ||
57 | ? new Date(VideoViewsManager.Instance.buildViewerExpireTime()).toISOString() | ||
58 | : undefined | ||
59 | }, | ||
60 | audience | ||
61 | ) | ||
62 | } | ||