diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
commit | fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58 (patch) | |
tree | bd626648077f84fb4628af3a37acf260597fa0ef /server/models/account | |
parent | f68d1cb6ac4aa4fb563b9eeb831fccffee260b2f (diff) | |
download | PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.gz PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.zst PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.zip |
Filter host for channels and playlists search
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 665ecd595..37194a119 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -52,6 +52,7 @@ export enum ScopeNames { | |||
52 | export type SummaryOptions = { | 52 | export type SummaryOptions = { |
53 | actorRequired?: boolean // Default: true | 53 | actorRequired?: boolean // Default: true |
54 | whereActor?: WhereOptions | 54 | whereActor?: WhereOptions |
55 | whereServer?: WhereOptions | ||
55 | withAccountBlockerIds?: number[] | 56 | withAccountBlockerIds?: number[] |
56 | } | 57 | } |
57 | 58 | ||
@@ -65,12 +66,11 @@ export type SummaryOptions = { | |||
65 | })) | 66 | })) |
66 | @Scopes(() => ({ | 67 | @Scopes(() => ({ |
67 | [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => { | 68 | [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => { |
68 | const whereActor = options.whereActor || undefined | ||
69 | |||
70 | const serverInclude: IncludeOptions = { | 69 | const serverInclude: IncludeOptions = { |
71 | attributes: [ 'host' ], | 70 | attributes: [ 'host' ], |
72 | model: ServerModel.unscoped(), | 71 | model: ServerModel.unscoped(), |
73 | required: false | 72 | required: !!options.whereServer, |
73 | where: options.whereServer | ||
74 | } | 74 | } |
75 | 75 | ||
76 | const queryInclude: Includeable[] = [ | 76 | const queryInclude: Includeable[] = [ |
@@ -78,7 +78,7 @@ export type SummaryOptions = { | |||
78 | attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ], | 78 | attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ], |
79 | model: ActorModel.unscoped(), | 79 | model: ActorModel.unscoped(), |
80 | required: options.actorRequired ?? true, | 80 | required: options.actorRequired ?? true, |
81 | where: whereActor, | 81 | where: options.whereActor, |
82 | include: [ | 82 | include: [ |
83 | serverInclude, | 83 | serverInclude, |
84 | 84 | ||