aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/actor/actor-follow.ts22
-rw-r--r--server/models/video/video-channel.ts24
2 files changed, 31 insertions, 15 deletions
diff --git a/server/models/actor/actor-follow.ts b/server/models/actor/actor-follow.ts
index fc1cc7499..d6a2387a5 100644
--- a/server/models/actor/actor-follow.ts
+++ b/server/models/actor/actor-follow.ts
@@ -143,7 +143,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
143 * @deprecated Use `findOrCreateCustom` instead 143 * @deprecated Use `findOrCreateCustom` instead
144 */ 144 */
145 static findOrCreate (): any { 145 static findOrCreate (): any {
146 throw new Error('Should not be called') 146 throw new Error('Must not be called')
147 } 147 }
148 148
149 // findOrCreate has issues with actor follow hooks 149 // findOrCreate has issues with actor follow hooks
@@ -288,7 +288,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
288 return ActorFollowModel.findOne(query) 288 return ActorFollowModel.findOne(query)
289 } 289 }
290 290
291 static listSubscribedIn (actorId: number, targets: { name: string, host?: string }[]): Promise<MActorFollowFollowingHost[]> { 291 static listSubscriptionsOf (actorId: number, targets: { name: string, host?: string }[]): Promise<MActorFollowFollowingHost[]> {
292 const whereTab = targets 292 const whereTab = targets
293 .map(t => { 293 .map(t => {
294 if (t.host) { 294 if (t.host) {
@@ -348,7 +348,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
348 return ActorFollowModel.findAll(query) 348 return ActorFollowModel.findAll(query)
349 } 349 }
350 350
351 static listFollowingForApi (options: { 351 static listInstanceFollowingForApi (options: {
352 id: number 352 id: number
353 start: number 353 start: number
354 count: number 354 count: number
@@ -415,7 +415,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
415 } 415 }
416 416
417 static listFollowersForApi (options: { 417 static listFollowersForApi (options: {
418 actorId: number 418 actorIds: number[]
419 start: number 419 start: number
420 count: number 420 count: number
421 sort: string 421 sort: string
@@ -423,7 +423,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
423 actorType?: ActivityPubActorType 423 actorType?: ActivityPubActorType
424 search?: string 424 search?: string
425 }) { 425 }) {
426 const { actorId, start, count, sort, search, state, actorType } = options 426 const { actorIds, start, count, sort, search, state, actorType } = options
427 427
428 const followWhere = state ? { state } : {} 428 const followWhere = state ? { state } : {}
429 const followerWhere: WhereOptions = {} 429 const followerWhere: WhereOptions = {}
@@ -452,20 +452,16 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
452 model: ActorModel, 452 model: ActorModel,
453 required: true, 453 required: true,
454 as: 'ActorFollower', 454 as: 'ActorFollower',
455 where: followerWhere, 455 where: followerWhere
456 include: [
457 {
458 model: ServerModel,
459 required: true
460 }
461 ]
462 }, 456 },
463 { 457 {
464 model: ActorModel, 458 model: ActorModel,
465 as: 'ActorFollowing', 459 as: 'ActorFollowing',
466 required: true, 460 required: true,
467 where: { 461 where: {
468 id: actorId 462 id: {
463 [Op.in]: actorIds
464 }
469 } 465 }
470 } 466 }
471 ] 467 ]
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 8ccb818b3..a151ad61c 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -26,7 +26,7 @@ import {
26 isVideoChannelDisplayNameValid, 26 isVideoChannelDisplayNameValid,
27 isVideoChannelSupportValid 27 isVideoChannelSupportValid
28} from '../../helpers/custom-validators/video-channels' 28} from '../../helpers/custom-validators/video-channels'
29import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' 29import { CONSTRAINTS_FIELDS, VIDEO_CHANNELS, WEBSERVER } from '../../initializers/constants'
30import { sendDeleteActor } from '../../lib/activitypub/send' 30import { sendDeleteActor } from '../../lib/activitypub/send'
31import { 31import {
32 MChannelActor, 32 MChannelActor,
@@ -527,7 +527,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
527 }) 527 })
528 } 528 }
529 529
530 static listByAccount (options: { 530 static listByAccountForAPI (options: {
531 accountId: number 531 accountId: number
532 start: number 532 start: number
533 count: number 533 count: number
@@ -582,6 +582,26 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
582 }) 582 })
583 } 583 }
584 584
585
586 static listAllByAccount (accountId: number) {
587 const query = {
588 limit: VIDEO_CHANNELS.MAX_PER_USER,
589 include: [
590 {
591 attributes: [],
592 model: AccountModel,
593 where: {
594 id: accountId
595 },
596 required: true
597 }
598 ]
599 }
600
601 return VideoChannelModel.findAll(query)
602 }
603
604
585 static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise<MChannelBannerAccountDefault> { 605 static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise<MChannelBannerAccountDefault> {
586 return VideoChannelModel.unscoped() 606 return VideoChannelModel.unscoped()
587 .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ]) 607 .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])