MUserId,
MVideoAccountLight,
MVideoAccountLightBlacklistAllFiles,
+ MVideoAP,
MVideoDetails,
+ MVideoFormattable,
+ MVideoFormattableDetails,
MVideoForUser,
MVideoFullLight,
MVideoIdThumbnail,
MVideoThumbnail,
- MVideoWithAllFiles, MVideoWithFile,
- MVideoWithRights,
- MVideoFormattable
+ MVideoThumbnailBlacklist,
+ MVideoWithAllFiles,
+ MVideoWithFile,
+ MVideoWithRights
} from '../../typings/models'
import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
import { MThumbnail } from '../../typings/models/video/thumbnail'
// FIXME: issues with sequelize count when making a join on n:m relation, so we just make a IN()
if (options.tagsAllOf || options.tagsOneOf) {
if (options.tagsOneOf) {
+ const tagsOneOfLower = options.tagsOneOf.map(t => t.toLowerCase())
+
whereAnd.push({
id: {
[ Op.in ]: Sequelize.literal(
'(' +
'SELECT "videoId" FROM "videoTag" ' +
'INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
- 'WHERE "tag"."name" IN (' + createSafeIn(VideoModel, options.tagsOneOf) + ')' +
+ 'WHERE lower("tag"."name") IN (' + createSafeIn(VideoModel, tagsOneOfLower) + ')' +
')'
)
}
}
if (options.tagsAllOf) {
+ const tagsAllOfLower = options.tagsAllOf.map(t => t.toLowerCase())
+
whereAnd.push({
id: {
[ Op.in ]: Sequelize.literal(
'(' +
'SELECT "videoId" FROM "videoTag" ' +
'INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
- 'WHERE "tag"."name" IN (' + createSafeIn(VideoModel, options.tagsAllOf) + ')' +
- 'GROUP BY "videoTag"."videoId" HAVING COUNT(*) = ' + options.tagsAllOf.length +
+ 'WHERE lower("tag"."name") IN (' + createSafeIn(VideoModel, tagsAllOfLower) + ')' +
+ 'GROUP BY "videoTag"."videoId" HAVING COUNT(*) = ' + tagsAllOfLower.length +
')'
)
}
return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options)
}
+ static loadWithBlacklist (id: number | string, t?: Transaction): Bluebird<MVideoThumbnailBlacklist> {
+ const where = buildWhereIdOrUUID(id)
+ const options = {
+ where,
+ transaction: t
+ }
+
+ return VideoModel.scope([
+ ScopeNames.WITH_THUMBNAILS,
+ ScopeNames.WITH_BLACKLISTED
+ ]).findOne(options)
+ }
+
static loadWithRights (id: number | string, t?: Transaction): Bluebird<MVideoWithRights> {
const where = buildWhereIdOrUUID(id)
const options = {
return join(LAZY_STATIC_PATHS.PREVIEWS, preview.filename)
}
- toFormattedJSON <T extends MVideoFormattable> (this: T, options?: VideoFormattingJSONOptions): Video {
+ toFormattedJSON (this: MVideoFormattable, options?: VideoFormattingJSONOptions): Video {
return videoModelToFormattedJSON(this, options)
}
- toFormattedDetailsJSON (): VideoDetails {
+ toFormattedDetailsJSON (this: MVideoFormattableDetails): VideoDetails {
return videoModelToFormattedDetailsJSON(this)
}
return videoFilesModelToFormattedJSON(this, this.VideoFiles)
}
- toActivityPubObject (): VideoTorrentObject {
+ toActivityPubObject (this: MVideoAP): VideoTorrentObject {
return videoModelToActivityPubObject(this)
}