diff options
Diffstat (limited to 'server/models/video/sql/video/shared/video-table-attributes.ts')
-rw-r--r-- | server/models/video/sql/video/shared/video-table-attributes.ts | 269 |
1 files changed, 269 insertions, 0 deletions
diff --git a/server/models/video/sql/video/shared/video-table-attributes.ts b/server/models/video/sql/video/shared/video-table-attributes.ts new file mode 100644 index 000000000..df2ed3fb0 --- /dev/null +++ b/server/models/video/sql/video/shared/video-table-attributes.ts | |||
@@ -0,0 +1,269 @@ | |||
1 | |||
2 | /** | ||
3 | * | ||
4 | * Class to build video attributes/join names we want to fetch from the database | ||
5 | * | ||
6 | */ | ||
7 | export class VideoTableAttributes { | ||
8 | |||
9 | constructor (readonly mode: 'get' | 'list') { | ||
10 | |||
11 | } | ||
12 | |||
13 | getChannelAttributesForUser () { | ||
14 | return [ 'id', 'accountId' ] | ||
15 | } | ||
16 | |||
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 | |||
36 | getUserAccountAttributes () { | ||
37 | return [ 'id', 'userId' ] | ||
38 | } | ||
39 | |||
40 | getAccountAttributes () { | ||
41 | let attributeKeys = [ 'id', 'name', 'actorId' ] | ||
42 | |||
43 | if (this.mode === 'get') { | ||
44 | attributeKeys = attributeKeys.concat([ | ||
45 | 'description', | ||
46 | 'userId', | ||
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 | 'storage' | ||
92 | ] | ||
93 | } | ||
94 | |||
95 | getStreamingPlaylistAttributes () { | ||
96 | return [ | ||
97 | 'id', | ||
98 | 'playlistUrl', | ||
99 | 'playlistFilename', | ||
100 | 'type', | ||
101 | 'p2pMediaLoaderInfohashes', | ||
102 | 'p2pMediaLoaderPeerVersion', | ||
103 | 'segmentsSha256Filename', | ||
104 | 'segmentsSha256Url', | ||
105 | 'videoId', | ||
106 | 'createdAt', | ||
107 | 'updatedAt', | ||
108 | 'storage' | ||
109 | ] | ||
110 | } | ||
111 | |||
112 | getUserHistoryAttributes () { | ||
113 | return [ 'id', 'currentTime' ] | ||
114 | } | ||
115 | |||
116 | getPlaylistAttributes () { | ||
117 | return [ | ||
118 | 'createdAt', | ||
119 | 'updatedAt', | ||
120 | 'url', | ||
121 | 'position', | ||
122 | 'startTimestamp', | ||
123 | 'stopTimestamp', | ||
124 | 'videoPlaylistId' | ||
125 | ] | ||
126 | } | ||
127 | |||
128 | getTagAttributes () { | ||
129 | return [ 'id', 'name' ] | ||
130 | } | ||
131 | |||
132 | getVideoTagAttributes () { | ||
133 | return [ 'videoId', 'tagId', 'createdAt', 'updatedAt' ] | ||
134 | } | ||
135 | |||
136 | getBlacklistedAttributes () { | ||
137 | return [ 'id', 'reason', 'unfederated' ] | ||
138 | } | ||
139 | |||
140 | getBlocklistAttributes () { | ||
141 | return [ 'id' ] | ||
142 | } | ||
143 | |||
144 | getScheduleUpdateAttributes () { | ||
145 | return [ | ||
146 | 'id', | ||
147 | 'updateAt', | ||
148 | 'privacy', | ||
149 | 'videoId', | ||
150 | 'createdAt', | ||
151 | 'updatedAt' | ||
152 | ] | ||
153 | } | ||
154 | |||
155 | getLiveAttributes () { | ||
156 | return [ | ||
157 | 'id', | ||
158 | 'streamKey', | ||
159 | 'saveReplay', | ||
160 | 'permanentLive', | ||
161 | 'videoId', | ||
162 | 'createdAt', | ||
163 | 'updatedAt' | ||
164 | ] | ||
165 | } | ||
166 | |||
167 | getTrackerAttributes () { | ||
168 | return [ 'id', 'url' ] | ||
169 | } | ||
170 | |||
171 | getVideoTrackerAttributes () { | ||
172 | return [ | ||
173 | 'videoId', | ||
174 | 'trackerId', | ||
175 | 'createdAt', | ||
176 | 'updatedAt' | ||
177 | ] | ||
178 | } | ||
179 | |||
180 | getRedundancyAttributes () { | ||
181 | return [ 'id', 'fileUrl' ] | ||
182 | } | ||
183 | |||
184 | getActorAttributes () { | ||
185 | let attributeKeys = [ | ||
186 | 'id', | ||
187 | 'preferredUsername', | ||
188 | 'url', | ||
189 | 'serverId' | ||
190 | ] | ||
191 | |||
192 | if (this.mode === 'get') { | ||
193 | attributeKeys = attributeKeys.concat([ | ||
194 | 'type', | ||
195 | 'followersCount', | ||
196 | 'followingCount', | ||
197 | 'inboxUrl', | ||
198 | 'outboxUrl', | ||
199 | 'sharedInboxUrl', | ||
200 | 'followersUrl', | ||
201 | 'followingUrl', | ||
202 | 'remoteCreatedAt', | ||
203 | 'createdAt', | ||
204 | 'updatedAt' | ||
205 | ]) | ||
206 | } | ||
207 | |||
208 | return attributeKeys | ||
209 | } | ||
210 | |||
211 | getAvatarAttributes () { | ||
212 | let attributeKeys = [ | ||
213 | 'id', | ||
214 | 'width', | ||
215 | 'filename', | ||
216 | 'type', | ||
217 | 'fileUrl', | ||
218 | 'onDisk', | ||
219 | 'createdAt', | ||
220 | 'updatedAt' | ||
221 | ] | ||
222 | |||
223 | if (this.mode === 'get') { | ||
224 | attributeKeys = attributeKeys.concat([ | ||
225 | 'height', | ||
226 | 'width', | ||
227 | 'type' | ||
228 | ]) | ||
229 | } | ||
230 | |||
231 | return attributeKeys | ||
232 | } | ||
233 | |||
234 | getServerAttributes () { | ||
235 | return [ 'id', 'host' ] | ||
236 | } | ||
237 | |||
238 | getVideoAttributes () { | ||
239 | return [ | ||
240 | 'id', | ||
241 | 'uuid', | ||
242 | 'name', | ||
243 | 'category', | ||
244 | 'licence', | ||
245 | 'language', | ||
246 | 'privacy', | ||
247 | 'nsfw', | ||
248 | 'description', | ||
249 | 'support', | ||
250 | 'duration', | ||
251 | 'views', | ||
252 | 'likes', | ||
253 | 'dislikes', | ||
254 | 'remote', | ||
255 | 'isLive', | ||
256 | 'url', | ||
257 | 'commentsEnabled', | ||
258 | 'downloadEnabled', | ||
259 | 'waitTranscoding', | ||
260 | 'state', | ||
261 | 'publishedAt', | ||
262 | 'originallyPublishedAt', | ||
263 | 'channelId', | ||
264 | 'createdAt', | ||
265 | 'updatedAt', | ||
266 | 'moveJobsRunning' | ||
267 | ] | ||
268 | } | ||
269 | } | ||