]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/sql/video/shared/video-table-attributes.ts
Feature/Add replay privacy (#5692)
[github/Chocobozzz/PeerTube.git] / server / models / video / sql / video / shared / video-table-attributes.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 */
7e7d8e48 7export class VideoTableAttributes {
d9bf974f 8
156c44c8 9 constructor (private readonly mode: 'get' | 'list') {
d9bf974f
C
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',
0305db28
JB
90 'videoId',
91 'storage'
d9bf974f
C
92 ]
93 }
94
95 getStreamingPlaylistAttributes () {
7e7d8e48
C
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 ]
d9bf974f
C
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
2760b454
C
140 getBlocklistAttributes () {
141 return [ 'id' ]
142 }
143
d9bf974f
C
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',
f443a746 161 'latencyMode',
d9bf974f 162 'videoId',
05a60d85 163 'replaySettingId',
d9bf974f
C
164 'createdAt',
165 'updatedAt'
166 ]
167 }
168
169 getTrackerAttributes () {
170 return [ 'id', 'url' ]
171 }
172
173 getVideoTrackerAttributes () {
174 return [
175 'videoId',
176 'trackerId',
177 'createdAt',
178 'updatedAt'
179 ]
180 }
181
182 getRedundancyAttributes () {
183 return [ 'id', 'fileUrl' ]
184 }
185
186 getActorAttributes () {
187 let attributeKeys = [
188 'id',
189 'preferredUsername',
190 'url',
d0800f76 191 'serverId'
d9bf974f
C
192 ]
193
194 if (this.mode === 'get') {
195 attributeKeys = attributeKeys.concat([
196 'type',
197 'followersCount',
198 'followingCount',
199 'inboxUrl',
200 'outboxUrl',
201 'sharedInboxUrl',
202 'followersUrl',
203 'followingUrl',
204 'remoteCreatedAt',
205 'createdAt',
206 'updatedAt'
207 ])
208 }
209
210 return attributeKeys
211 }
212
213 getAvatarAttributes () {
214 let attributeKeys = [
215 'id',
d0800f76 216 'width',
d9bf974f 217 'filename',
17bb4538 218 'type',
d9bf974f
C
219 'fileUrl',
220 'onDisk',
221 'createdAt',
222 'updatedAt'
223 ]
224
225 if (this.mode === 'get') {
226 attributeKeys = attributeKeys.concat([
227 'height',
228 'width',
229 'type'
230 ])
231 }
232
233 return attributeKeys
234 }
235
236 getServerAttributes () {
237 return [ 'id', 'host' ]
238 }
239
240 getVideoAttributes () {
241 return [
242 'id',
243 'uuid',
244 'name',
245 'category',
246 'licence',
247 'language',
248 'privacy',
249 'nsfw',
250 'description',
251 'support',
252 'duration',
253 'views',
254 'likes',
255 'dislikes',
256 'remote',
257 'isLive',
258 'url',
259 'commentsEnabled',
260 'downloadEnabled',
261 'waitTranscoding',
262 'state',
263 'publishedAt',
264 'originallyPublishedAt',
265 'channelId',
266 'createdAt',
0305db28
JB
267 'updatedAt',
268 'moveJobsRunning'
d9bf974f
C
269 ]
270 }
271}