await Promise.all(tasks)
}
- static listLocal (): Promise<MVideo[]> {
+ static listLocalIds (): Promise<number[]> {
const query = {
+ attributes: [ 'id' ],
+ raw: true,
where: {
remote: false
}
}
return VideoModel.findAll(query)
+ .then(rows => rows.map(r => r.id))
}
static listAllAndSharedByActorForOutbox (actorId: number, start: number, count: number) {
include?: VideoInclude
hasFiles?: boolean // default false
+ hasWebtorrentFiles?: boolean
+ hasHLSFiles?: boolean
categoryOneOf?: number[]
licenceOneOf?: number[]
search?: string
}) {
- if (VideoModel.isPrivateInclude(options.include) && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) {
- throw new Error('Try to filter all-local but no user has not the see all videos right')
- }
+ VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
const trendingDays = options.sort.endsWith('trending')
? CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
'videoPlaylistId',
'user',
'historyOfUser',
+ 'hasHLSFiles',
+ 'hasWebtorrentFiles',
'search'
]),
start: number
count: number
sort: string
- search?: string
- host?: string
- startDate?: string // ISO 8601
- endDate?: string // ISO 8601
- originallyPublishedStartDate?: string
- originallyPublishedEndDate?: string
+
nsfw?: boolean
isLive?: boolean
isLocal?: boolean
include?: VideoInclude
+
categoryOneOf?: number[]
licenceOneOf?: number[]
languageOneOf?: string[]
tagsOneOf?: string[]
tagsAllOf?: string[]
+
+ displayOnlyForFollower: DisplayOnlyForFollowerOptions | null
+
+ user?: MUserAccountId
+
+ hasWebtorrentFiles?: boolean
+ hasHLSFiles?: boolean
+
+ search?: string
+
+ host?: string
+ startDate?: string // ISO 8601
+ endDate?: string // ISO 8601
+ originallyPublishedStartDate?: string
+ originallyPublishedEndDate?: string
+
durationMin?: number // seconds
durationMax?: number // seconds
- user?: MUserAccountId
uuids?: string[]
- displayOnlyForFollower: DisplayOnlyForFollowerOptions | null
}) {
+ VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
+
const serverActor = await getServerActor()
const queryOptions = {
'originallyPublishedEndDate',
'durationMin',
'durationMax',
+ 'hasHLSFiles',
+ 'hasWebtorrentFiles',
'uuids',
'search',
'displayOnlyForFollower'
}
}
+ private static throwIfPrivateIncludeWithoutUser (include: VideoInclude, user: MUserAccountId) {
+ if (VideoModel.isPrivateInclude(include) && !user?.hasRight(UserRight.SEE_ALL_VIDEOS)) {
+ throw new Error('Try to filter all-local but no user has not the see all videos right')
+ }
+ }
+
private static isPrivateInclude (include: VideoInclude) {
return include & VideoInclude.BLACKLISTED ||
include & VideoInclude.BLOCKED_OWNER ||
if (Array.isArray(this.Thumbnails) === false) this.Thumbnails = []
- // Already have this thumbnail, skip
- if (this.Thumbnails.find(t => t.id === savedThumbnail.id)) return
-
+ this.Thumbnails = this.Thumbnails.filter(t => t.id !== savedThumbnail.id)
this.Thumbnails.push(savedThumbnail)
}
if (!this.VideoStreamingPlaylists) return undefined
const playlist = this.VideoStreamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
+ if (!playlist) return undefined
+
playlist.Video = this
return playlist
return this.hasPrivacyForFederation() === false && isPrivacyForFederation(newPrivacy) === true
}
- setAsRefreshed () {
- return setAsUpdated('video', this.id)
+ setAsRefreshed (transaction?: Transaction) {
+ return setAsUpdated('video', this.id, transaction)
}
requiresAuth () {
await this.save({ transaction })
}
- getBandwidthBits (videoFile: MVideoFile) {
+ getBandwidthBits (this: MVideo, videoFile: MVideoFile) {
return Math.ceil((videoFile.size * 8) / this.duration)
}