aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts26
1 files changed, 20 insertions, 6 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 070ac7623..4f3f75613 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -235,7 +235,14 @@ type AvailableForListIDsOptions = {
235 ) 235 )
236 } 236 }
237 ] 237 ]
238 }, 238 }
239 },
240 include: []
241 }
242
243 // Only list public/published videos
244 if (!options.filter || options.filter !== 'all-local') {
245 const privacyWhere = {
239 // Always list public videos 246 // Always list public videos
240 privacy: VideoPrivacy.PUBLIC, 247 privacy: VideoPrivacy.PUBLIC,
241 // Always list published videos, or videos that are being transcoded but on which we don't want to wait for transcoding 248 // Always list published videos, or videos that are being transcoded but on which we don't want to wait for transcoding
@@ -250,8 +257,9 @@ type AvailableForListIDsOptions = {
250 } 257 }
251 } 258 }
252 ] 259 ]
253 }, 260 }
254 include: [] 261
262 Object.assign(query.where, privacyWhere)
255 } 263 }
256 264
257 if (options.filter || options.accountId || options.videoChannelId) { 265 if (options.filter || options.accountId || options.videoChannelId) {
@@ -969,6 +977,10 @@ export class VideoModel extends Model<VideoModel> {
969 trendingDays?: number, 977 trendingDays?: number,
970 userId?: number 978 userId?: number
971 }, countVideos = true) { 979 }, countVideos = true) {
980 if (options.filter && options.filter === 'all-local' && !options.userId) {
981 throw new Error('Try to filter all-local but no userId is provided')
982 }
983
972 const query: IFindOptions<VideoModel> = { 984 const query: IFindOptions<VideoModel> = {
973 offset: options.start, 985 offset: options.start,
974 limit: options.count, 986 limit: options.count,
@@ -1021,7 +1033,8 @@ export class VideoModel extends Model<VideoModel> {
1021 tagsAllOf?: string[] 1033 tagsAllOf?: string[]
1022 durationMin?: number // seconds 1034 durationMin?: number // seconds
1023 durationMax?: number // seconds 1035 durationMax?: number // seconds
1024 userId?: number 1036 userId?: number,
1037 filter?: VideoFilter
1025 }) { 1038 }) {
1026 const whereAnd = [] 1039 const whereAnd = []
1027 1040
@@ -1098,7 +1111,8 @@ export class VideoModel extends Model<VideoModel> {
1098 languageOneOf: options.languageOneOf, 1111 languageOneOf: options.languageOneOf,
1099 tagsOneOf: options.tagsOneOf, 1112 tagsOneOf: options.tagsOneOf,
1100 tagsAllOf: options.tagsAllOf, 1113 tagsAllOf: options.tagsAllOf,
1101 userId: options.userId 1114 userId: options.userId,
1115 filter: options.filter
1102 } 1116 }
1103 1117
1104 return VideoModel.getAvailableForApi(query, queryOptions) 1118 return VideoModel.getAvailableForApi(query, queryOptions)
@@ -1262,7 +1276,7 @@ export class VideoModel extends Model<VideoModel> {
1262 } 1276 }
1263 1277
1264 private static buildActorWhereWithFilter (filter?: VideoFilter) { 1278 private static buildActorWhereWithFilter (filter?: VideoFilter) {
1265 if (filter && filter === 'local') { 1279 if (filter && (filter === 'local' || filter === 'all-local')) {
1266 return { 1280 return {
1267 serverId: null 1281 serverId: null
1268 } 1282 }