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