diff options
Diffstat (limited to 'server/models/video/sql/shared/abstract-videos-model-query-builder.ts')
-rw-r--r-- | server/models/video/sql/shared/abstract-videos-model-query-builder.ts | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts index 65df8d914..d959cb5d0 100644 --- a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts +++ b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts | |||
@@ -80,6 +80,18 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | protected includeOwnerUser () { | ||
84 | this.addJoin('INNER JOIN "videoChannel" AS "VideoChannel" ON "video"."channelId" = "VideoChannel"."id"') | ||
85 | this.addJoin('INNER JOIN "account" AS "VideoChannel->Account" ON "VideoChannel"."accountId" = "VideoChannel->Account"."id"') | ||
86 | |||
87 | this.attributes = { | ||
88 | ...this.attributes, | ||
89 | |||
90 | ...this.buildAttributesObject('VideoChannel', this.tables.getChannelAttributes()), | ||
91 | ...this.buildAttributesObject('VideoChannel->Account', this.tables.getUserAccountAttributes()) | ||
92 | } | ||
93 | } | ||
94 | |||
83 | protected includeThumbnails () { | 95 | protected includeThumbnails () { |
84 | this.addJoin('LEFT OUTER JOIN "thumbnail" AS "Thumbnails" ON "video"."id" = "Thumbnails"."videoId"') | 96 | this.addJoin('LEFT OUTER JOIN "thumbnail" AS "Thumbnails" ON "video"."id" = "Thumbnails"."videoId"') |
85 | 97 | ||
@@ -269,14 +281,20 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
269 | return result | 281 | return result |
270 | } | 282 | } |
271 | 283 | ||
272 | protected whereId (id: string | number) { | 284 | protected whereId (options: { id?: string | number, url?: string }) { |
273 | if (validator.isInt('' + id)) { | 285 | if (options.url) { |
286 | this.where = 'WHERE "video"."url" = :videoUrl' | ||
287 | this.replacements.videoUrl = options.url | ||
288 | return | ||
289 | } | ||
290 | |||
291 | if (validator.isInt('' + options.id)) { | ||
274 | this.where = 'WHERE "video".id = :videoId' | 292 | this.where = 'WHERE "video".id = :videoId' |
275 | } else { | 293 | } else { |
276 | this.where = 'WHERE uuid = :videoId' | 294 | this.where = 'WHERE uuid = :videoId' |
277 | } | 295 | } |
278 | 296 | ||
279 | this.replacements.videoId = id | 297 | this.replacements.videoId = options.id |
280 | } | 298 | } |
281 | 299 | ||
282 | protected addJoin (join: string) { | 300 | protected addJoin (join: string) { |