diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-08 11:52:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-08 11:52:43 +0200 |
commit | 0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6 (patch) | |
tree | 6ec1d1c4262811066224eff8c4a55865fdaa9d08 /shared/utils | |
parent | ae9bbed46dbc8d9870c9feb66bbada484c1c7582 (diff) | |
download | PeerTube-0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6.tar.gz PeerTube-0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6.tar.zst PeerTube-0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6.zip |
Add ability to remove an instance follower in API
Diffstat (limited to 'shared/utils')
-rw-r--r-- | shared/utils/server/follows.ts | 13 |
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 | |||
47 | async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) { | 47 | async 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 | 57 | function 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 | ||
59 | async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { | 67 | async 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 | } |