diff options
Diffstat (limited to 'server/models/redundancy')
-rw-r--r-- | server/models/redundancy/video-redundancy.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 98c6ff134..74895fe30 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -185,6 +185,57 @@ export class VideoRedundancyModel extends Model { | |||
185 | return VideoRedundancyModel.scope(ScopeNames.WITH_VIDEO).findOne(query) | 185 | return VideoRedundancyModel.scope(ScopeNames.WITH_VIDEO).findOne(query) |
186 | } | 186 | } |
187 | 187 | ||
188 | static async listLocalByVideoId (videoId: number): Promise<MVideoRedundancyVideo[]> { | ||
189 | const actor = await getServerActor() | ||
190 | |||
191 | const queryStreamingPlaylist = { | ||
192 | where: { | ||
193 | actorId: actor.id | ||
194 | }, | ||
195 | include: [ | ||
196 | { | ||
197 | model: VideoStreamingPlaylistModel.unscoped(), | ||
198 | required: true, | ||
199 | include: [ | ||
200 | { | ||
201 | model: VideoModel.unscoped(), | ||
202 | required: true, | ||
203 | where: { | ||
204 | id: videoId | ||
205 | } | ||
206 | } | ||
207 | ] | ||
208 | } | ||
209 | ] | ||
210 | } | ||
211 | |||
212 | const queryFiles = { | ||
213 | where: { | ||
214 | actorId: actor.id | ||
215 | }, | ||
216 | include: [ | ||
217 | { | ||
218 | model: VideoFileModel, | ||
219 | required: true, | ||
220 | include: [ | ||
221 | { | ||
222 | model: VideoModel, | ||
223 | required: true, | ||
224 | where: { | ||
225 | id: videoId | ||
226 | } | ||
227 | } | ||
228 | ] | ||
229 | } | ||
230 | ] | ||
231 | } | ||
232 | |||
233 | return Promise.all([ | ||
234 | VideoRedundancyModel.findAll(queryStreamingPlaylist), | ||
235 | VideoRedundancyModel.findAll(queryFiles) | ||
236 | ]).then(([ r1, r2 ]) => r1.concat(r2)) | ||
237 | } | ||
238 | |||
188 | static async loadLocalByStreamingPlaylistId (videoStreamingPlaylistId: number): Promise<MVideoRedundancyVideo> { | 239 | static async loadLocalByStreamingPlaylistId (videoStreamingPlaylistId: number): Promise<MVideoRedundancyVideo> { |
189 | const actor = await getServerActor() | 240 | const actor = await getServerActor() |
190 | 241 | ||