aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/server/follows.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-08 11:52:29 +0200
committerChocobozzz <me@florianbigard.com>2019-04-08 11:52:43 +0200
commit0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6 (patch)
tree6ec1d1c4262811066224eff8c4a55865fdaa9d08 /shared/utils/server/follows.ts
parentae9bbed46dbc8d9870c9feb66bbada484c1c7582 (diff)
downloadPeerTube-0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6.tar.gz
PeerTube-0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6.tar.zst
PeerTube-0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6.zip
Add ability to remove an instance follower in API
Diffstat (limited to 'shared/utils/server/follows.ts')
-rw-r--r--shared/utils/server/follows.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/shared/utils/server/follows.ts b/shared/utils/server/follows.ts
index 7741757a6..949fd8109 100644
--- a/shared/utils/server/follows.ts
+++ b/shared/utils/server/follows.ts
@@ -47,13 +47,21 @@ async function follow (follower: string, following: string[], accessToken: strin
47async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) { 47async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) {
48 const path = '/api/v1/server/following/' + target.host 48 const path = '/api/v1/server/following/' + target.host
49 49
50 const res = await request(url) 50 return request(url)
51 .delete(path) 51 .delete(path)
52 .set('Accept', 'application/json') 52 .set('Accept', 'application/json')
53 .set('Authorization', 'Bearer ' + accessToken) 53 .set('Authorization', 'Bearer ' + accessToken)
54 .expect(expectedStatus) 54 .expect(expectedStatus)
55}
55 56
56 return res 57function removeFollower (url: string, accessToken: string, follower: ServerInfo, expectedStatus = 204) {
58 const path = '/api/v1/server/followers/peertube@' + follower.host
59
60 return request(url)
61 .delete(path)
62 .set('Accept', 'application/json')
63 .set('Authorization', 'Bearer ' + accessToken)
64 .expect(expectedStatus)
57} 65}
58 66
59async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { 67async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
@@ -74,6 +82,7 @@ export {
74 getFollowersListPaginationAndSort, 82 getFollowersListPaginationAndSort,
75 getFollowingListPaginationAndSort, 83 getFollowingListPaginationAndSort,
76 unfollow, 84 unfollow,
85 removeFollower,
77 follow, 86 follow,
78 doubleFollow 87 doubleFollow
79} 88}