]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
694361276c23c8bc051dfe9ad2046c4219b26226
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
1 import { ContextType } from '@server/helpers/activitypub'
2 import { SendEmailOptions } from './emailer.model'
3 import { VideoResolution } from '@shared/models'
4
5 export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed'
6
7 export type JobType =
8 | 'activitypub-http-unicast'
9 | 'activitypub-http-broadcast'
10 | 'activitypub-http-fetcher'
11 | 'activitypub-follow'
12 | 'video-file-import'
13 | 'video-transcoding'
14 | 'email'
15 | 'video-import'
16 | 'videos-views'
17 | 'activitypub-refresher'
18 | 'video-redundancy'
19
20 export interface Job {
21 id: number
22 state: JobState
23 type: JobType
24 data: any
25 error: any
26 createdAt: Date | string
27 finishedOn: Date | string
28 processedOn: Date | string
29 }
30
31 export type ActivitypubHttpBroadcastPayload = {
32 uris: string[]
33 signatureActorId?: number
34 body: any
35 contextType?: ContextType
36 }
37
38 export type ActivitypubFollowPayload = {
39 followerActorId: number
40 name: string
41 host: string
42 isAutoFollow?: boolean
43 assertIsChannel?: boolean
44 }
45
46 export type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists'
47 export type ActivitypubHttpFetcherPayload = {
48 uri: string
49 type: FetchType
50 videoId?: number
51 accountId?: number
52 }
53
54 export type ActivitypubHttpUnicastPayload = {
55 uri: string
56 signatureActorId?: number
57 body: any
58 contextType?: ContextType
59 }
60
61 export type RefreshPayload = {
62 type: 'video' | 'video-playlist' | 'actor'
63 url: string
64 }
65
66 export type EmailPayload = SendEmailOptions
67
68 export type VideoFileImportPayload = {
69 videoUUID: string
70 filePath: string
71 }
72
73 export type VideoImportYoutubeDLPayload = {
74 type: 'youtube-dl'
75 videoImportId: number
76
77 generateThumbnail: boolean
78 generatePreview: boolean
79
80 fileExt?: string
81 }
82 export type VideoImportTorrentPayload = {
83 type: 'magnet-uri' | 'torrent-file'
84 videoImportId: number
85 }
86 export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload
87
88 export type VideoRedundancyPayload = {
89 videoId: number
90 }
91
92 // Video transcoding payloads
93
94 interface BaseTranscodingPayload {
95 videoUUID: string
96 isNewVideo?: boolean
97 }
98
99 interface HLSTranscodingPayload extends BaseTranscodingPayload {
100 type: 'hls'
101 isPortraitMode?: boolean
102 resolution: VideoResolution
103 copyCodecs: boolean
104 }
105
106 export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload {
107 type: 'new-resolution'
108 isPortraitMode?: boolean
109 resolution: VideoResolution
110 }
111
112 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
113 type: 'merge-audio'
114 resolution: VideoResolution
115 }
116
117 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
118 type: 'optimize'
119 }
120
121 export type VideoTranscodingPayload =
122 HLSTranscodingPayload
123 | NewResolutionTranscodingPayload
124 | OptimizeTranscodingPayload
125 | MergeAudioTranscodingPayload