]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/sql/shared/video-tables.ts
Fix missing delete cascade video -> channel
[github/Chocobozzz/PeerTube.git] / server / models / video / sql / shared / video-tables.ts
CommitLineData
1d43c3a6
C
1
2/**
3 *
17bb4538 4 * Class to build video attributes/join names we want to fetch from the database
1d43c3a6
C
5 *
6 */
17bb4538 7export class VideoTables {
d9bf974f
C
8
9 constructor (readonly mode: 'get' | 'list') {
10
11 }
12
71d4af1e
C
13 getChannelAttributesForUser () {
14 return [ 'id', 'accountId' ]
15 }
16
d9bf974f
C
17 getChannelAttributes () {
18 let attributeKeys = [
19 'id',
20 'name',
21 'description',
22 'actorId'
23 ]
24
25 if (this.mode === 'get') {
26 attributeKeys = attributeKeys.concat([
27 'support',
28 'createdAt',
29 'updatedAt'
30 ])
31 }
32
33 return attributeKeys
34 }
35
71d4af1e
C
36 getUserAccountAttributes () {
37 return [ 'id', 'userId' ]
38 }
39
d9bf974f
C
40 getAccountAttributes () {
41 let attributeKeys = [ 'id', 'name', 'actorId' ]
42
43 if (this.mode === 'get') {
44 attributeKeys = attributeKeys.concat([
45 'description',
b8afe6f0 46 'userId',
d9bf974f
C
47 'createdAt',
48 'updatedAt'
49 ])
50 }
51
52 return attributeKeys
53 }
54
55 getThumbnailAttributes () {
56 let attributeKeys = [ 'id', 'type', 'filename' ]
57
58 if (this.mode === 'get') {
59 attributeKeys = attributeKeys.concat([
60 'height',
61 'width',
62 'fileUrl',
63 'automaticallyGenerated',
64 'videoId',
65 'videoPlaylistId',
66 'createdAt',
67 'updatedAt'
68 ])
69 }
70
71 return attributeKeys
72 }
73
74 getFileAttributes () {
75 return [
76 'id',
77 'createdAt',
78 'updatedAt',
79 'resolution',
80 'size',
81 'extname',
82 'filename',
83 'fileUrl',
84 'torrentFilename',
85 'torrentUrl',
86 'infoHash',
87 'fps',
88 'metadataUrl',
89 'videoStreamingPlaylistId',
90 'videoId'
91 ]
92 }
93
94 getStreamingPlaylistAttributes () {
95 let playlistKeys = [ 'id', 'playlistUrl', 'type' ]
96
97 if (this.mode === 'get') {
98 playlistKeys = playlistKeys.concat([
99 'p2pMediaLoaderInfohashes',
100 'p2pMediaLoaderPeerVersion',
101 'segmentsSha256Url',
102 'videoId',
103 'createdAt',
104 'updatedAt'
105 ])
106 }
107
108 return playlistKeys
109 }
110
111 getUserHistoryAttributes () {
112 return [ 'id', 'currentTime' ]
113 }
114
115 getPlaylistAttributes () {
116 return [
117 'createdAt',
118 'updatedAt',
119 'url',
120 'position',
121 'startTimestamp',
122 'stopTimestamp',
123 'videoPlaylistId'
124 ]
125 }
126
127 getTagAttributes () {
128 return [ 'id', 'name' ]
129 }
130
131 getVideoTagAttributes () {
132 return [ 'videoId', 'tagId', 'createdAt', 'updatedAt' ]
133 }
134
135 getBlacklistedAttributes () {
136 return [ 'id', 'reason', 'unfederated' ]
137 }
138
139 getScheduleUpdateAttributes () {
140 return [
141 'id',
142 'updateAt',
143 'privacy',
144 'videoId',
145 'createdAt',
146 'updatedAt'
147 ]
148 }
149
150 getLiveAttributes () {
151 return [
152 'id',
153 'streamKey',
154 'saveReplay',
155 'permanentLive',
156 'videoId',
157 'createdAt',
158 'updatedAt'
159 ]
160 }
161
162 getTrackerAttributes () {
163 return [ 'id', 'url' ]
164 }
165
166 getVideoTrackerAttributes () {
167 return [
168 'videoId',
169 'trackerId',
170 'createdAt',
171 'updatedAt'
172 ]
173 }
174
175 getRedundancyAttributes () {
176 return [ 'id', 'fileUrl' ]
177 }
178
179 getActorAttributes () {
180 let attributeKeys = [
181 'id',
182 'preferredUsername',
183 'url',
184 'serverId',
185 'avatarId'
186 ]
187
188 if (this.mode === 'get') {
189 attributeKeys = attributeKeys.concat([
190 'type',
191 'followersCount',
192 'followingCount',
193 'inboxUrl',
194 'outboxUrl',
195 'sharedInboxUrl',
196 'followersUrl',
197 'followingUrl',
198 'remoteCreatedAt',
199 'createdAt',
200 'updatedAt'
201 ])
202 }
203
204 return attributeKeys
205 }
206
207 getAvatarAttributes () {
208 let attributeKeys = [
209 'id',
210 'filename',
17bb4538 211 'type',
d9bf974f
C
212 'fileUrl',
213 'onDisk',
214 'createdAt',
215 'updatedAt'
216 ]
217
218 if (this.mode === 'get') {
219 attributeKeys = attributeKeys.concat([
220 'height',
221 'width',
222 'type'
223 ])
224 }
225
226 return attributeKeys
227 }
228
229 getServerAttributes () {
230 return [ 'id', 'host' ]
231 }
232
233 getVideoAttributes () {
234 return [
235 'id',
236 'uuid',
237 'name',
238 'category',
239 'licence',
240 'language',
241 'privacy',
242 'nsfw',
243 'description',
244 'support',
245 'duration',
246 'views',
247 'likes',
248 'dislikes',
249 'remote',
250 'isLive',
251 'url',
252 'commentsEnabled',
253 'downloadEnabled',
254 'waitTranscoding',
255 'state',
256 'publishedAt',
257 'originallyPublishedAt',
258 'channelId',
259 'createdAt',
260 'updatedAt'
261 ]
262 }
263}