aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/account.ts23
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'
18import { sendDeleteActor } from '../../lib/activitypub/send' 18import { sendDeleteActor } from '../../lib/activitypub/send'
19import { ActorModel } from '../activitypub/actor' 19import { ActorModel } from '../activitypub/actor'
20import { ApplicationModel } from '../application/application' 20import { ApplicationModel } from '../application/application'
21import { AvatarModel } from '../avatar/avatar'
21import { ServerModel } from '../server/server' 22import { ServerModel } from '../server/server'
22import { throwIfNotValid } from '../utils' 23import { getSort, throwIfNotValid } from '../utils'
23import { VideoChannelModel } from '../video/video-channel' 24import { VideoChannelModel } from '../video/video-channel'
24import { UserModel } from './user' 25import { 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 = {