aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/utils')
-rw-r--r--shared/utils/server/config.ts3
-rw-r--r--shared/utils/server/follows.ts33
2 files changed, 30 insertions, 6 deletions
diff --git a/shared/utils/server/config.ts b/shared/utils/server/config.ts
index 21c689714..deb77e9c0 100644
--- a/shared/utils/server/config.ts
+++ b/shared/utils/server/config.ts
@@ -122,7 +122,8 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) {
122 }, 122 },
123 followers: { 123 followers: {
124 instance: { 124 instance: {
125 enabled: true 125 enabled: true,
126 manualApproval: false
126 } 127 }
127 } 128 }
128 } 129 }
diff --git a/shared/utils/server/follows.ts b/shared/utils/server/follows.ts
index 949fd8109..1505804de 100644
--- a/shared/utils/server/follows.ts
+++ b/shared/utils/server/follows.ts
@@ -1,6 +1,7 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { ServerInfo } from './servers' 2import { ServerInfo } from './servers'
3import { waitJobs } from './jobs' 3import { waitJobs } from './jobs'
4import { makeGetRequest, makePostBodyRequest } from '..'
4 5
5function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { 6function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) {
6 const path = '/api/v1/server/followers' 7 const path = '/api/v1/server/followers'
@@ -16,6 +17,28 @@ function getFollowersListPaginationAndSort (url: string, start: number, count: n
16 .expect('Content-Type', /json/) 17 .expect('Content-Type', /json/)
17} 18}
18 19
20function acceptFollower (url: string, token: string, follower: string, statusCodeExpected = 204) {
21 const path = '/api/v1/server/followers/' + follower + '/accept'
22
23 return makePostBodyRequest({
24 url,
25 token,
26 path,
27 statusCodeExpected
28 })
29}
30
31function rejectFollower (url: string, token: string, follower: string, statusCodeExpected = 204) {
32 const path = '/api/v1/server/followers/' + follower + '/reject'
33
34 return makePostBodyRequest({
35 url,
36 token,
37 path,
38 statusCodeExpected
39 })
40}
41
19function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { 42function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) {
20 const path = '/api/v1/server/following' 43 const path = '/api/v1/server/following'
21 44
@@ -30,18 +53,16 @@ function getFollowingListPaginationAndSort (url: string, start: number, count: n
30 .expect('Content-Type', /json/) 53 .expect('Content-Type', /json/)
31} 54}
32 55
33async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { 56function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) {
34 const path = '/api/v1/server/following' 57 const path = '/api/v1/server/following'
35 58
36 const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) 59 const followingHosts = following.map(f => f.replace(/^http:\/\//, ''))
37 const res = await request(follower) 60 return request(follower)
38 .post(path) 61 .post(path)
39 .set('Accept', 'application/json') 62 .set('Accept', 'application/json')
40 .set('Authorization', 'Bearer ' + accessToken) 63 .set('Authorization', 'Bearer ' + accessToken)
41 .send({ 'hosts': followingHosts }) 64 .send({ 'hosts': followingHosts })
42 .expect(expectedStatus) 65 .expect(expectedStatus)
43
44 return res
45} 66}
46 67
47async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) { 68async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) {
@@ -84,5 +105,7 @@ export {
84 unfollow, 105 unfollow,
85 removeFollower, 106 removeFollower,
86 follow, 107 follow,
87 doubleFollow 108 doubleFollow,
109 acceptFollower,
110 rejectFollower
88} 111}