aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/account.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-03 16:38:50 +0100
committerChocobozzz <me@florianbigard.com>2018-01-03 16:38:50 +0100
commit265ba139ebf56bbdc1c65f6ea4f367774c691fc0 (patch)
treec7c52d1ae48a35b8f9aa06a9fa2335a6ba502fd1 /server/models/account/account.ts
parent9bce811268cd74b402176ae9fcd8b77ac887576e (diff)
downloadPeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.gz
PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.zst
PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.zip
Send account activitypub update events
Diffstat (limited to 'server/models/account/account.ts')
-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 = {