diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/sql/videos-id-list-query-builder.ts | 19 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 6 |
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 @@ | |||
1 | import { Sequelize } from 'sequelize' | 1 | import { Sequelize } from 'sequelize' |
2 | import validator from 'validator' | 2 | import validator from 'validator' |
3 | import { exists } from '@server/helpers/custom-validators/misc' | 3 | import { exists } from '@server/helpers/custom-validators/misc' |
4 | import { WEBSERVER } from '@server/initializers/constants' | ||
4 | import { buildDirectionAndField, createSafeIn } from '@server/models/utils' | 5 | import { buildDirectionAndField, createSafeIn } from '@server/models/utils' |
5 | import { MUserAccountId, MUserId } from '@server/types/models' | 6 | import { MUserAccountId, MUserId } from '@server/types/models' |
6 | import { VideoFilter, VideoPrivacy, VideoState } from '@shared/models' | 7 | import { 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 { | |||
20 | import { setAsUpdated } from '@server/helpers/database-utils' | 20 | import { setAsUpdated } from '@server/helpers/database-utils' |
21 | import { buildUUID, uuidToShort } from '@server/helpers/uuid' | 21 | import { buildUUID, uuidToShort } from '@server/helpers/uuid' |
22 | import { MAccountId, MChannelId } from '@server/types/models' | 22 | import { MAccountId, MChannelId } from '@server/types/models' |
23 | import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistLink, buildPlaylistWatchPath } from '@shared/core-utils' | 23 | import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistWatchPath } from '@shared/core-utils' |
24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
25 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' | 25 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' |
26 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 26 | import { 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' |
27 | import { setAsUpdated } from '@server/helpers/database-utils' | 27 | import { setAsUpdated } from '@server/helpers/database-utils' |
28 | import { buildNSFWFilter } from '@server/helpers/express-utils' | 28 | import { buildNSFWFilter } from '@server/helpers/express-utils' |
29 | import { shortToUUID } from '@server/helpers/uuid' | 29 | import { uuidToShort } from '@server/helpers/uuid' |
30 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' | 30 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' |
31 | import { LiveManager } from '@server/lib/live/live-manager' | 31 | import { LiveManager } from '@server/lib/live/live-manager' |
32 | import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' | 32 | import { 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 () { |