}
}
- static listForApi (parameters: {
- actorId: number
- start: number
- count: number
- sort: string
- }) {
- const { actorId } = parameters
-
- const query = {
- offset: parameters.start,
- limit: parameters.count,
- order: getSort(parameters.sort)
- }
-
- return VideoChannelModel
- .scope({
- method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ]
- })
- .findAndCountAll(query)
- .then(({ rows, count }) => {
- return { total: count, data: rows }
- })
- }
-
static listLocalsForSitemap (sort: string): Promise<MChannelActor[]> {
const query = {
attributes: [ ],
.findAll(query)
}
- static searchForApi (options: {
- actorId: number
- search?: string
+ static listForApi (parameters: Pick<AvailableForListOptions, 'actorId'> & {
start: number
count: number
sort: string
+ }) {
+ const { actorId } = parameters
+
+ const query = {
+ offset: parameters.start,
+ limit: parameters.count,
+ order: getSort(parameters.sort)
+ }
+
+ return VideoChannelModel
+ .scope({
+ method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ]
+ })
+ .findAndCountAll(query)
+ .then(({ rows, count }) => {
+ return { total: count, data: rows }
+ })
+ }
- host?: string
- handles?: string[]
+ static searchForApi (options: Pick<AvailableForListOptions, 'actorId' | 'search' | 'host' | 'handles'> & {
+ start: number
+ count: number
+ sort: string
}) {
let attributesInclude: any[] = [ literal('0 as similarity') ]
let where: WhereOptions
} from 'sequelize-typescript'
import { buildUUID, uuidToShort } from '@server/helpers/uuid'
import { MAccountId, MChannelId } from '@server/types/models'
-import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistWatchPath } from '@shared/core-utils'
+import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'
import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
})
Thumbnail: ThumbnailModel
- static listForApi (options: {
- followerActorId: number
+ static listForApi (options: AvailableForListOptions & {
start: number
count: number
sort: string
- type?: VideoPlaylistType
- accountId?: number
- videoChannelId?: number
- listMyPlaylists?: boolean
- search?: string
- host?: string
- uuids?: string[]
- withVideos?: boolean // false by default
}) {
const query = {
offset: options.start,
method: [
ScopeNames.AVAILABLE_FOR_LIST,
{
- type: options.type,
- followerActorId: options.followerActorId,
- accountId: options.accountId,
- videoChannelId: options.videoChannelId,
- listMyPlaylists: options.listMyPlaylists,
- search: options.search,
- host: options.host,
- uuids: options.uuids,
+ ...pick(options, [ 'type', 'followerActorId', 'accountId', 'videoChannelId', 'listMyPlaylists', 'search', 'host', 'uuids' ]),
+
withVideos: options.withVideos || false
} as AvailableForListOptions
]
})
}
- static searchForApi (options: {
- followerActorId: number
+ static searchForApi (options: Pick<AvailableForListOptions, 'followerActorId' | 'search'| 'host'| 'uuids'> & {
start: number
count: number
sort: string
- search?: string
- host?: string
- uuids?: string[]
}) {
return VideoPlaylistModel.listForApi({
...options,
+
type: VideoPlaylistType.REGULAR,
listMyPlaylists: false,
withVideos: true
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'
: 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
host?: string
- start?: number
- count?: number
- sort?: string
startDate?: string // ISO 8601
endDate?: string // ISO 8601
originallyPublishedStartDate?: string
const serverActor = await getServerActor()
const queryOptions = {
- followerActorId: serverActor.id,
- serverAccountId: serverActor.Account.id,
-
- includeLocalVideos: options.includeLocalVideos,
- nsfw: options.nsfw,
- isLive: options.isLive,
-
- categoryOneOf: options.categoryOneOf,
- licenceOneOf: options.licenceOneOf,
- languageOneOf: options.languageOneOf,
+ ...pick(options, [
+ 'includeLocalVideos',
+ 'nsfw',
+ 'isLive',
+ 'categoryOneOf',
+ 'licenceOneOf',
+ 'languageOneOf',
+ 'tagsOneOf',
+ 'tagsAllOf',
+ 'user',
+ 'filter',
+ 'host',
+ 'start',
+ 'count',
+ 'sort',
+ 'startDate',
+ 'endDate',
+ 'originallyPublishedStartDate',
+ 'originallyPublishedEndDate',
+ 'durationMin',
+ 'durationMax',
+ 'uuids',
+ 'search'
+ ]),
- tagsOneOf: options.tagsOneOf,
- tagsAllOf: options.tagsAllOf,
-
- user: options.user,
- filter: options.filter,
- host: options.host,
-
- 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,
-
- uuids: options.uuids,
-
- search: options.search
+ followerActorId: serverActor.id,
+ serverAccountId: serverActor.Account.id
}
return VideoModel.getAvailableForApi(queryOptions)