diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-03 16:38:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-03 16:38:50 +0100 |
commit | 265ba139ebf56bbdc1c65f6ea4f367774c691fc0 (patch) | |
tree | c7c52d1ae48a35b8f9aa06a9fa2335a6ba502fd1 /server/controllers/api/accounts.ts | |
parent | 9bce811268cd74b402176ae9fcd8b77ac887576e (diff) | |
download | PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.gz PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.zst PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.zip |
Send account activitypub update events
Diffstat (limited to 'server/controllers/api/accounts.ts')
-rw-r--r-- | server/controllers/api/accounts.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts new file mode 100644 index 000000000..aded581a5 --- /dev/null +++ b/server/controllers/api/accounts.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import * as express from 'express' | ||
2 | import { getFormattedObjects } from '../../helpers/utils' | ||
3 | import { asyncMiddleware, paginationValidator, setAccountsSort, setPagination } from '../../middlewares' | ||
4 | import { accountsGetValidator, accountsSortValidator } from '../../middlewares/validators' | ||
5 | import { AccountModel } from '../../models/account/account' | ||
6 | |||
7 | const accountsRouter = express.Router() | ||
8 | |||
9 | accountsRouter.get('/', | ||
10 | paginationValidator, | ||
11 | accountsSortValidator, | ||
12 | setAccountsSort, | ||
13 | setPagination, | ||
14 | asyncMiddleware(listAccounts) | ||
15 | ) | ||
16 | |||
17 | accountsRouter.get('/:id', | ||
18 | asyncMiddleware(accountsGetValidator), | ||
19 | getAccount | ||
20 | ) | ||
21 | |||
22 | // --------------------------------------------------------------------------- | ||
23 | |||
24 | export { | ||
25 | accountsRouter | ||
26 | } | ||
27 | |||
28 | // --------------------------------------------------------------------------- | ||
29 | |||
30 | function getAccount (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
31 | return res.json(res.locals.account.toFormattedJSON()) | ||
32 | } | ||
33 | |||
34 | async function listAccounts (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
35 | const resultList = await AccountModel.listForApi(req.query.start, req.query.count, req.query.sort) | ||
36 | |||
37 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | ||
38 | } | ||