aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts52
1 files changed, 23 insertions, 29 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index e4b12c517..9f04a57c6 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -438,30 +438,6 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
438 } 438 }
439 } 439 }
440 440
441 static listForApi (parameters: {
442 actorId: number
443 start: number
444 count: number
445 sort: string
446 }) {
447 const { actorId } = parameters
448
449 const query = {
450 offset: parameters.start,
451 limit: parameters.count,
452 order: getSort(parameters.sort)
453 }
454
455 return VideoChannelModel
456 .scope({
457 method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ]
458 })
459 .findAndCountAll(query)
460 .then(({ rows, count }) => {
461 return { total: count, data: rows }
462 })
463 }
464
465 static listLocalsForSitemap (sort: string): Promise<MChannelActor[]> { 441 static listLocalsForSitemap (sort: string): Promise<MChannelActor[]> {
466 const query = { 442 const query = {
467 attributes: [ ], 443 attributes: [ ],
@@ -483,15 +459,33 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
483 .findAll(query) 459 .findAll(query)
484 } 460 }
485 461
486 static searchForApi (options: { 462 static listForApi (parameters: Pick<AvailableForListOptions, 'actorId'> & {
487 actorId: number
488 search?: string
489 start: number 463 start: number
490 count: number 464 count: number
491 sort: string 465 sort: string
466 }) {
467 const { actorId } = parameters
468
469 const query = {
470 offset: parameters.start,
471 limit: parameters.count,
472 order: getSort(parameters.sort)
473 }
474
475 return VideoChannelModel
476 .scope({
477 method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ]
478 })
479 .findAndCountAll(query)
480 .then(({ rows, count }) => {
481 return { total: count, data: rows }
482 })
483 }
492 484
493 host?: string 485 static searchForApi (options: Pick<AvailableForListOptions, 'actorId' | 'search' | 'host' | 'handles'> & {
494 handles?: string[] 486 start: number
487 count: number
488 sort: string
495 }) { 489 }) {
496 let attributesInclude: any[] = [ literal('0 as similarity') ] 490 let attributesInclude: any[] = [ literal('0 as similarity') ]
497 let where: WhereOptions 491 let where: WhereOptions