]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
Use got instead of request
[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-cleaner'
12 | 'activitypub-follow'
13 | 'video-file-import'
14 | 'video-transcoding'
15 | 'email'
16 | 'video-import'
17 | 'videos-views'
18 | 'activitypub-refresher'
19 | 'video-redundancy'
20 | 'video-live-ending'
21 | 'actor-keys'
22
23 export interface Job {
24 id: number
25 state: JobState
26 type: JobType
27 data: any
28 priority: number
29 progress: number
30 error: any
31 createdAt: Date | string
32 finishedOn: Date | string
33 processedOn: Date | string
34 }
35
36 export type ActivitypubHttpBroadcastPayload = {
37 uris: string[]
38 signatureActorId?: number
39 body: any
40 contextType?: ContextType
41 }
42
43 export type ActivitypubFollowPayload = {
44 followerActorId: number
45 name: string
46 host: string
47 isAutoFollow?: boolean
48 assertIsChannel?: boolean
49 }
50
51 export type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists'
52 export type ActivitypubHttpFetcherPayload = {
53 uri: string
54 type: FetchType
55 videoId?: number
56 accountId?: number
57 }
58
59 export type ActivitypubHttpUnicastPayload = {
60 uri: string
61 signatureActorId?: number
62 body: object
63 contextType?: ContextType
64 }
65
66 export type RefreshPayload = {
67 type: 'video' | 'video-playlist' | 'actor'
68 url: string
69 }
70
71 export type EmailPayload = SendEmailOptions
72
73 export type VideoFileImportPayload = {
74 videoUUID: string
75 filePath: string
76 }
77
78 export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
79 export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
80
81 export type VideoImportYoutubeDLPayload = {
82 type: VideoImportYoutubeDLPayloadType
83 videoImportId: number
84
85 fileExt?: 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 export interface HLSTranscodingPayload extends BaseTranscodingPayload {
105 type: 'new-resolution-to-hls'
106 isPortraitMode?: boolean
107 resolution: VideoResolution
108 copyCodecs: boolean
109 isMaxQuality: boolean
110 }
111
112 export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload {
113 type: 'new-resolution-to-webtorrent'
114 isPortraitMode?: boolean
115 resolution: VideoResolution
116 }
117
118 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
119 type: 'merge-audio-to-webtorrent'
120 resolution: VideoResolution
121 }
122
123 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
124 type: 'optimize-to-webtorrent'
125 }
126
127 export type VideoTranscodingPayload =
128 HLSTranscodingPayload
129 | NewResolutionTranscodingPayload
130 | OptimizeTranscodingPayload
131 | MergeAudioTranscodingPayload
132
133 export interface VideoLiveEndingPayload {
134 videoId: number
135 }
136
137 export interface ActorKeysPayload {
138 actorId: number
139 }