aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils
diff options
context:
space:
mode:
authorYohan Boniface <yohanboniface@free.fr>2019-04-09 11:02:02 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-04-09 11:02:02 +0200
commitc100a6142e6571312db9f6407698a21a08b593fb (patch)
treec80ac9c7754b8f5b133255e003557937e415ee23 /shared/utils
parent8ce1ba6e3efe0a688d6a0b57e8201cde33ad7aac (diff)
downloadPeerTube-c100a6142e6571312db9f6407698a21a08b593fb.tar.gz
PeerTube-c100a6142e6571312db9f6407698a21a08b593fb.tar.zst
PeerTube-c100a6142e6571312db9f6407698a21a08b593fb.zip
Add /accounts/:username/ratings endpoint (#1756)
* Add /users/me/videos/ratings endpoint * Move ratings endpoint from users to accounts * /accounts/:name/ratings: add support for rating= and sort= * Restrict ratings list to owner * Wording and better way to ensure current account
Diffstat (limited to 'shared/utils')
-rw-r--r--shared/utils/index.ts1
-rw-r--r--shared/utils/users/accounts.ts16
2 files changed, 16 insertions, 1 deletions
diff --git a/shared/utils/index.ts b/shared/utils/index.ts
index c09565d95..469546872 100644
--- a/shared/utils/index.ts
+++ b/shared/utils/index.ts
@@ -15,6 +15,7 @@ export * from './server/servers'
15export * from './videos/services' 15export * from './videos/services'
16export * from './videos/video-playlists' 16export * from './videos/video-playlists'
17export * from './users/users' 17export * from './users/users'
18export * from './users/accounts'
18export * from './videos/video-abuses' 19export * from './videos/video-abuses'
19export * from './videos/video-blacklist' 20export * from './videos/video-blacklist'
20export * from './videos/video-channels' 21export * from './videos/video-channels'
diff --git a/shared/utils/users/accounts.ts b/shared/utils/users/accounts.ts
index 388eb6973..54d66ac2a 100644
--- a/shared/utils/users/accounts.ts
+++ b/shared/utils/users/accounts.ts
@@ -1,5 +1,6 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import * as request from 'supertest'
3import { expect } from 'chai' 4import { expect } from 'chai'
4import { existsSync, readdir } from 'fs-extra' 5import { existsSync, readdir } from 'fs-extra'
5import { join } from 'path' 6import { join } from 'path'
@@ -53,11 +54,24 @@ async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: numb
53 } 54 }
54} 55}
55 56
57function getAccountRatings (url: string, accountName: string, accessToken: string, statusCodeExpected = 200, query = {}) {
58 const path = '/api/v1/accounts/' + accountName + '/ratings'
59
60 return request(url)
61 .get(path)
62 .query(query)
63 .set('Accept', 'application/json')
64 .set('Authorization', 'Bearer ' + accessToken)
65 .expect(statusCodeExpected)
66 .expect('Content-Type', /json/)
67}
68
56// --------------------------------------------------------------------------- 69// ---------------------------------------------------------------------------
57 70
58export { 71export {
59 getAccount, 72 getAccount,
60 expectAccountFollows, 73 expectAccountFollows,
61 getAccountsList, 74 getAccountsList,
62 checkActorFilesWereRemoved 75 checkActorFilesWereRemoved,
76 getAccountRatings
63} 77}