aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/sql/videos-id-list-query-builder.ts19
-rw-r--r--server/models/video/video-playlist.ts2
-rw-r--r--server/models/video/video.ts6
3 files changed, 24 insertions, 3 deletions
diff --git a/server/models/video/sql/videos-id-list-query-builder.ts b/server/models/video/sql/videos-id-list-query-builder.ts
index 054f71c8c..d4260c69c 100644
--- a/server/models/video/sql/videos-id-list-query-builder.ts
+++ b/server/models/video/sql/videos-id-list-query-builder.ts
@@ -1,6 +1,7 @@
1import { Sequelize } from 'sequelize' 1import { Sequelize } from 'sequelize'
2import validator from 'validator' 2import validator from 'validator'
3import { exists } from '@server/helpers/custom-validators/misc' 3import { exists } from '@server/helpers/custom-validators/misc'
4import { WEBSERVER } from '@server/initializers/constants'
4import { buildDirectionAndField, createSafeIn } from '@server/models/utils' 5import { buildDirectionAndField, createSafeIn } from '@server/models/utils'
5import { MUserAccountId, MUserId } from '@server/types/models' 6import { MUserAccountId, MUserId } from '@server/types/models'
6import { VideoFilter, VideoPrivacy, VideoState } from '@shared/models' 7import { VideoFilter, VideoPrivacy, VideoState } from '@shared/models'
@@ -25,6 +26,7 @@ export type BuildVideosListQueryOptions = {
25 26
26 nsfw?: boolean 27 nsfw?: boolean
27 filter?: VideoFilter 28 filter?: VideoFilter
29 host?: string
28 isLive?: boolean 30 isLive?: boolean
29 31
30 categoryOneOf?: number[] 32 categoryOneOf?: number[]
@@ -131,6 +133,10 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder {
131 this.whereOnlyLocal() 133 this.whereOnlyLocal()
132 } 134 }
133 135
136 if (options.host) {
137 this.whereHost(options.host)
138 }
139
134 if (options.accountId) { 140 if (options.accountId) {
135 this.whereAccountId(options.accountId) 141 this.whereAccountId(options.accountId)
136 } 142 }
@@ -291,6 +297,19 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder {
291 this.and.push('"video"."remote" IS FALSE') 297 this.and.push('"video"."remote" IS FALSE')
292 } 298 }
293 299
300 private whereHost (host: string) {
301 // Local instance
302 if (host === WEBSERVER.HOST) {
303 this.and.push('"accountActor"."serverId" IS NULL')
304 return
305 }
306
307 this.joins.push('INNER JOIN "server" ON "server"."id" = "accountActor"."serverId"')
308
309 this.and.push('"server"."host" = :host')
310 this.replacements.host = host
311 }
312
294 private whereAccountId (accountId: number) { 313 private whereAccountId (accountId: number) {
295 this.and.push('"account"."id" = :accountId') 314 this.and.push('"account"."id" = :accountId')
296 this.replacements.accountId = accountId 315 this.replacements.accountId = accountId
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index 245475f94..72ba474b4 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -20,7 +20,7 @@ import {
20import { setAsUpdated } from '@server/helpers/database-utils' 20import { setAsUpdated } from '@server/helpers/database-utils'
21import { buildUUID, uuidToShort } from '@server/helpers/uuid' 21import { buildUUID, uuidToShort } from '@server/helpers/uuid'
22import { MAccountId, MChannelId } from '@server/types/models' 22import { MAccountId, MChannelId } from '@server/types/models'
23import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistLink, buildPlaylistWatchPath } from '@shared/core-utils' 23import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistWatchPath } from '@shared/core-utils'
24import { ActivityIconObject } from '../../../shared/models/activitypub/objects' 24import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
25import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' 25import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 543e604bb..c006a91af 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -26,7 +26,7 @@ import {
26} from 'sequelize-typescript' 26} from 'sequelize-typescript'
27import { setAsUpdated } from '@server/helpers/database-utils' 27import { setAsUpdated } from '@server/helpers/database-utils'
28import { buildNSFWFilter } from '@server/helpers/express-utils' 28import { buildNSFWFilter } from '@server/helpers/express-utils'
29import { shortToUUID } from '@server/helpers/uuid' 29import { uuidToShort } from '@server/helpers/uuid'
30import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' 30import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
31import { LiveManager } from '@server/lib/live/live-manager' 31import { LiveManager } from '@server/lib/live/live-manager'
32import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' 32import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths'
@@ -1113,6 +1113,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1113 static async searchAndPopulateAccountAndServer (options: { 1113 static async searchAndPopulateAccountAndServer (options: {
1114 includeLocalVideos: boolean 1114 includeLocalVideos: boolean
1115 search?: string 1115 search?: string
1116 host?: string
1116 start?: number 1117 start?: number
1117 count?: number 1118 count?: number
1118 sort?: string 1119 sort?: string
@@ -1151,6 +1152,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1151 1152
1152 user: options.user, 1153 user: options.user,
1153 filter: options.filter, 1154 filter: options.filter,
1155 host: options.host,
1154 1156
1155 start: options.start, 1157 start: options.start,
1156 count: options.count, 1158 count: options.count,
@@ -1579,7 +1581,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1579 } 1581 }
1580 1582
1581 getWatchStaticPath () { 1583 getWatchStaticPath () {
1582 return buildVideoWatchPath({ shortUUID: shortToUUID(this.uuid) }) 1584 return buildVideoWatchPath({ shortUUID: uuidToShort(this.uuid) })
1583 } 1585 }
1584 1586
1585 getEmbedStaticPath () { 1587 getEmbedStaticPath () {