aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users/user-subscriptions.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /shared/extra-utils/users/user-subscriptions.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'shared/extra-utils/users/user-subscriptions.ts')
-rw-r--r--shared/extra-utils/users/user-subscriptions.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/shared/extra-utils/users/user-subscriptions.ts b/shared/extra-utils/users/user-subscriptions.ts
index 6d402c073..edc7a3562 100644
--- a/shared/extra-utils/users/user-subscriptions.ts
+++ b/shared/extra-utils/users/user-subscriptions.ts
@@ -1,6 +1,7 @@
1import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../requests/requests' 1import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
2 3
3function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = 204) { 4function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
4 const path = '/api/v1/users/me/subscriptions' 5 const path = '/api/v1/users/me/subscriptions'
5 6
6 return makePostBodyRequest({ 7 return makePostBodyRequest({
@@ -19,7 +20,7 @@ function listUserSubscriptions (parameters: {
19 search?: string 20 search?: string
20 statusCodeExpected?: number 21 statusCodeExpected?: number
21}) { 22}) {
22 const { url, token, sort = '-createdAt', search, statusCodeExpected = 200 } = parameters 23 const { url, token, sort = '-createdAt', search, statusCodeExpected = HttpStatusCode.OK_200 } = parameters
23 const path = '/api/v1/users/me/subscriptions' 24 const path = '/api/v1/users/me/subscriptions'
24 25
25 return makeGetRequest({ 26 return makeGetRequest({
@@ -34,7 +35,7 @@ function listUserSubscriptions (parameters: {
34 }) 35 })
35} 36}
36 37
37function listUserSubscriptionVideos (url: string, token: string, sort = '-createdAt', statusCodeExpected = 200) { 38function listUserSubscriptionVideos (url: string, token: string, sort = '-createdAt', statusCodeExpected = HttpStatusCode.OK_200) {
38 const path = '/api/v1/users/me/subscriptions/videos' 39 const path = '/api/v1/users/me/subscriptions/videos'
39 40
40 return makeGetRequest({ 41 return makeGetRequest({
@@ -46,7 +47,7 @@ function listUserSubscriptionVideos (url: string, token: string, sort = '-create
46 }) 47 })
47} 48}
48 49
49function getUserSubscription (url: string, token: string, uri: string, statusCodeExpected = 200) { 50function getUserSubscription (url: string, token: string, uri: string, statusCodeExpected = HttpStatusCode.OK_200) {
50 const path = '/api/v1/users/me/subscriptions/' + uri 51 const path = '/api/v1/users/me/subscriptions/' + uri
51 52
52 return makeGetRequest({ 53 return makeGetRequest({
@@ -57,7 +58,7 @@ function getUserSubscription (url: string, token: string, uri: string, statusCod
57 }) 58 })
58} 59}
59 60
60function removeUserSubscription (url: string, token: string, uri: string, statusCodeExpected = 204) { 61function removeUserSubscription (url: string, token: string, uri: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
61 const path = '/api/v1/users/me/subscriptions/' + uri 62 const path = '/api/v1/users/me/subscriptions/' + uri
62 63
63 return makeDeleteRequest({ 64 return makeDeleteRequest({
@@ -68,7 +69,7 @@ function removeUserSubscription (url: string, token: string, uri: string, status
68 }) 69 })
69} 70}
70 71
71function areSubscriptionsExist (url: string, token: string, uris: string[], statusCodeExpected = 200) { 72function areSubscriptionsExist (url: string, token: string, uris: string[], statusCodeExpected = HttpStatusCode.OK_200) {
72 const path = '/api/v1/users/me/subscriptions/exist' 73 const path = '/api/v1/users/me/subscriptions/exist'
73 74
74 return makeGetRequest({ 75 return makeGetRequest({