import { VideoTagModel } from './video-tag'
import { ScheduleVideoUpdateModel } from './schedule-video-update'
import { VideoCaptionModel } from './video-caption'
+import { VideoBlacklistModel } from './video-blacklist'
// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
const indexes: Sequelize.DefineIndexesOptions[] = [
})
ScheduleVideoUpdate: ScheduleVideoUpdateModel
+ @HasOne(() => VideoBlacklistModel, {
+ foreignKey: {
+ name: 'videoId',
+ allowNull: false
+ },
+ onDelete: 'cascade'
+ })
+ VideoBlacklist: VideoBlacklistModel
+
@HasMany(() => VideoCaptionModel, {
foreignKey: {
name: 'videoId',
})
}
- static listUserVideosForApi (accountId: number, start: number, count: number, sort: string, hideNSFW: boolean, withFiles = false) {
+ static listUserVideosForApi (accountId: number, start: number, count: number, sort: string, withFiles = false) {
const query: IFindOptions<VideoModel> = {
offset: start,
limit: count,
{
model: ScheduleVideoUpdateModel,
required: false
+ },
+ {
+ model: VideoBlacklistModel,
+ required: false
}
]
}
})
}
- if (hideNSFW === true) {
- query.where = {
- nsfw: false
- }
- }
-
return VideoModel.findAndCountAll(query).then(({ rows, count }) => {
return {
data: rows,
additionalAttributes: {
state?: boolean,
waitTranscoding?: boolean,
- scheduledUpdate?: boolean
+ scheduledUpdate?: boolean,
+ blacklistInfo?: boolean
}
}): Video {
const formattedAccount = this.VideoChannel.Account.toFormattedJSON()
privacy: this.ScheduleVideoUpdate.privacy || undefined
}
}
+
+ if (options.additionalAttributes.blacklistInfo === true) {
+ videoObject.blacklisted = !!this.VideoBlacklist
+ videoObject.blacklistedReason = this.VideoBlacklist ? this.VideoBlacklist.reason : null
+ }
}
return videoObject