Table,
UpdatedAt
} from 'sequelize-typescript'
-import { setAsUpdated } from '@server/helpers/database-utils'
import { buildNSFWFilter } from '@server/helpers/express-utils'
-import { shortToUUID } from '@server/helpers/uuid'
+import { uuidToShort } from '@server/helpers/uuid'
import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
import { LiveManager } from '@server/lib/live/live-manager'
import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths'
import { getServerActor } from '@server/models/application/application'
import { ModelCache } from '@server/models/model-cache'
-import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath } from '@shared/core-utils'
+import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'
import { VideoFile } from '@shared/models/videos/video-file.model'
import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'
import { VideoObject } from '../../../shared/models/activitypub/objects'
import { ServerModel } from '../server/server'
import { TrackerModel } from '../server/tracker'
import { VideoTrackerModel } from '../server/video-tracker'
+import { setAsUpdated } from '../shared'
import { UserModel } from '../user/user'
import { UserVideoHistoryModel } from '../user/user-video-history'
import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils'
const trendingDays = options.sort.endsWith('trending')
? CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
: undefined
- let trendingAlgorithm
+
+ let trendingAlgorithm: string
if (options.sort.endsWith('hot')) trendingAlgorithm = 'hot'
if (options.sort.endsWith('best')) trendingAlgorithm = 'best'
: serverActor.id
const queryOptions = {
- start: options.start,
- count: options.count,
- sort: options.sort,
+ ...pick(options, [
+ 'start',
+ 'count',
+ 'sort',
+ 'nsfw',
+ 'isLive',
+ 'categoryOneOf',
+ 'licenceOneOf',
+ 'languageOneOf',
+ 'tagsOneOf',
+ 'tagsAllOf',
+ 'filter',
+ 'withFiles',
+ 'accountId',
+ 'videoChannelId',
+ 'videoPlaylistId',
+ 'includeLocalVideos',
+ 'user',
+ 'historyOfUser',
+ 'search'
+ ]),
+
followerActorId,
serverAccountId: serverActor.Account.id,
- nsfw: options.nsfw,
- isLive: options.isLive,
- categoryOneOf: options.categoryOneOf,
- licenceOneOf: options.licenceOneOf,
- languageOneOf: options.languageOneOf,
- tagsOneOf: options.tagsOneOf,
- tagsAllOf: options.tagsAllOf,
- filter: options.filter,
- withFiles: options.withFiles,
- accountId: options.accountId,
- videoChannelId: options.videoChannelId,
- videoPlaylistId: options.videoPlaylistId,
- includeLocalVideos: options.includeLocalVideos,
- user: options.user,
- historyOfUser: options.historyOfUser,
trendingDays,
- trendingAlgorithm,
- search: options.search
+ trendingAlgorithm
}
return VideoModel.getAvailableForApi(queryOptions, options.countVideos)
}
static async searchAndPopulateAccountAndServer (options: {
+ start: number
+ count: number
+ sort: string
includeLocalVideos: boolean
search?: string
- start?: number
- count?: number
- sort?: string
+ host?: string
startDate?: string // ISO 8601
endDate?: string // ISO 8601
originallyPublishedStartDate?: string
durationMax?: number // seconds
user?: MUserAccountId
filter?: VideoFilter
+ uuids?: string[]
}) {
const serverActor = await getServerActor()
const queryOptions = {
- followerActorId: serverActor.id,
- serverAccountId: serverActor.Account.id,
-
- includeLocalVideos: options.includeLocalVideos,
- nsfw: options.nsfw,
- isLive: options.isLive,
+ ...pick(options, [
+ 'includeLocalVideos',
+ 'nsfw',
+ 'isLive',
+ 'categoryOneOf',
+ 'licenceOneOf',
+ 'languageOneOf',
+ 'tagsOneOf',
+ 'tagsAllOf',
+ 'user',
+ 'filter',
+ 'host',
+ 'start',
+ 'count',
+ 'sort',
+ 'startDate',
+ 'endDate',
+ 'originallyPublishedStartDate',
+ 'originallyPublishedEndDate',
+ 'durationMin',
+ 'durationMax',
+ 'uuids',
+ 'search'
+ ]),
- categoryOneOf: options.categoryOneOf,
- licenceOneOf: options.licenceOneOf,
- languageOneOf: options.languageOneOf,
-
- tagsOneOf: options.tagsOneOf,
- tagsAllOf: options.tagsAllOf,
-
- user: options.user,
- filter: options.filter,
-
- start: options.start,
- count: options.count,
- sort: options.sort,
-
- startDate: options.startDate,
- endDate: options.endDate,
-
- originallyPublishedStartDate: options.originallyPublishedStartDate,
- originallyPublishedEndDate: options.originallyPublishedEndDate,
-
- durationMin: options.durationMin,
- durationMax: options.durationMax,
-
- search: options.search
+ followerActorId: serverActor.id,
+ serverAccountId: serverActor.Account.id
}
return VideoModel.getAvailableForApi(queryOptions)
}
getWatchStaticPath () {
- return buildVideoWatchPath({ shortUUID: shortToUUID(this.uuid) })
+ return buildVideoWatchPath({ shortUUID: uuidToShort(this.uuid) })
}
getEmbedStaticPath () {