diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index d3503aaa3..493068127 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -18,8 +18,9 @@ import { isUserUsernameValid } from '../../helpers/custom-validators/users' | |||
18 | import { sendDeleteActor } from '../../lib/activitypub/send' | 18 | import { sendDeleteActor } from '../../lib/activitypub/send' |
19 | import { ActorModel } from '../activitypub/actor' | 19 | import { ActorModel } from '../activitypub/actor' |
20 | import { ApplicationModel } from '../application/application' | 20 | import { ApplicationModel } from '../application/application' |
21 | import { AvatarModel } from '../avatar/avatar' | ||
21 | import { ServerModel } from '../server/server' | 22 | import { ServerModel } from '../server/server' |
22 | import { throwIfNotValid } from '../utils' | 23 | import { getSort, throwIfNotValid } from '../utils' |
23 | import { VideoChannelModel } from '../video/video-channel' | 24 | import { VideoChannelModel } from '../video/video-channel' |
24 | import { UserModel } from './user' | 25 | import { UserModel } from './user' |
25 | 26 | ||
@@ -32,6 +33,10 @@ import { UserModel } from './user' | |||
32 | { | 33 | { |
33 | model: () => ServerModel, | 34 | model: () => ServerModel, |
34 | required: false | 35 | required: false |
36 | }, | ||
37 | { | ||
38 | model: () => AvatarModel, | ||
39 | required: false | ||
35 | } | 40 | } |
36 | ] | 41 | ] |
37 | } | 42 | } |
@@ -166,6 +171,22 @@ export class AccountModel extends Model<AccountModel> { | |||
166 | return AccountModel.findOne(query) | 171 | return AccountModel.findOne(query) |
167 | } | 172 | } |
168 | 173 | ||
174 | static listForApi (start: number, count: number, sort: string) { | ||
175 | const query = { | ||
176 | offset: start, | ||
177 | limit: count, | ||
178 | order: [ getSort(sort) ] | ||
179 | } | ||
180 | |||
181 | return AccountModel.findAndCountAll(query) | ||
182 | .then(({ rows, count }) => { | ||
183 | return { | ||
184 | data: rows, | ||
185 | total: count | ||
186 | } | ||
187 | }) | ||
188 | } | ||
189 | |||
169 | toFormattedJSON (): Account { | 190 | toFormattedJSON (): Account { |
170 | const actor = this.Actor.toFormattedJSON() | 191 | const actor = this.Actor.toFormattedJSON() |
171 | const account = { | 192 | const account = { |