aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+admin/follows/follows.routes.ts2
-rw-r--r--client/src/app/+admin/follows/shared/follow.service.ts2
-rw-r--r--client/src/app/core/menu/menu-admin.component.html2
-rw-r--r--client/src/app/core/menu/menu-admin.component.ts4
-rw-r--r--client/src/app/core/menu/menu.component.ts4
-rw-r--r--server/controllers/api/index.ts4
-rw-r--r--server/controllers/api/server/follows.ts20
-rw-r--r--server/controllers/api/server/index.ts8
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/tests/utils/follows.ts53
-rw-r--r--server/tests/utils/pods.ts103
-rw-r--r--shared/models/users/user-right.enum.ts2
12 files changed, 78 insertions, 128 deletions
diff --git a/client/src/app/+admin/follows/follows.routes.ts b/client/src/app/+admin/follows/follows.routes.ts
index b7d44f75b..e84c79e82 100644
--- a/client/src/app/+admin/follows/follows.routes.ts
+++ b/client/src/app/+admin/follows/follows.routes.ts
@@ -13,7 +13,7 @@ export const FollowsRoutes: Routes = [
13 component: FollowsComponent, 13 component: FollowsComponent,
14 canActivate: [ UserRightGuard ], 14 canActivate: [ UserRightGuard ],
15 data: { 15 data: {
16 userRight: UserRight.MANAGE_APPLICATION_FOLLOW 16 userRight: UserRight.MANAGE_SERVER_FOLLOW
17 }, 17 },
18 children: [ 18 children: [
19 { 19 {
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts
index 3dc91dfca..d64361ee3 100644
--- a/client/src/app/+admin/follows/shared/follow.service.ts
+++ b/client/src/app/+admin/follows/shared/follow.service.ts
@@ -11,7 +11,7 @@ import { AccountFollow, ResultList } from '../../../../../../shared'
11 11
12@Injectable() 12@Injectable()
13export class FollowService { 13export class FollowService {
14 private static BASE_APPLICATION_URL = API_URL + '/api/v1/application' 14 private static BASE_APPLICATION_URL = API_URL + '/api/v1/server'
15 15
16 constructor ( 16 constructor (
17 private authHttp: HttpClient, 17 private authHttp: HttpClient,
diff --git a/client/src/app/core/menu/menu-admin.component.html b/client/src/app/core/menu/menu-admin.component.html
index 99ee287c5..eb2d0d69c 100644
--- a/client/src/app/core/menu/menu-admin.component.html
+++ b/client/src/app/core/menu/menu-admin.component.html
@@ -5,7 +5,7 @@
5 List users 5 List users
6 </a> 6 </a>
7 7
8 <a *ngIf="hasApplicationFollowRight()" routerLink="/admin/follows" routerLinkActive="active"> 8 <a *ngIf="hasServerFollowRight()" routerLink="/admin/follows" routerLinkActive="active">
9 <span class="hidden-xs glyphicon glyphicon-cloud"></span> 9 <span class="hidden-xs glyphicon glyphicon-cloud"></span>
10 Manage follows 10 Manage follows
11 </a> 11 </a>
diff --git a/client/src/app/core/menu/menu-admin.component.ts b/client/src/app/core/menu/menu-admin.component.ts
index 88a654d1f..466da1aee 100644
--- a/client/src/app/core/menu/menu-admin.component.ts
+++ b/client/src/app/core/menu/menu-admin.component.ts
@@ -15,8 +15,8 @@ export class MenuAdminComponent {
15 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) 15 return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
16 } 16 }
17 17
18 hasApplicationFollowRight () { 18 hasServerFollowRight () {
19 return this.auth.getUser().hasRight(UserRight.MANAGE_APPLICATION_FOLLOW) 19 return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
20 } 20 }
21 21
22 hasVideoAbusesRight () { 22 hasVideoAbusesRight () {
diff --git a/client/src/app/core/menu/menu.component.ts b/client/src/app/core/menu/menu.component.ts
index 872d29819..d2bd71534 100644
--- a/client/src/app/core/menu/menu.component.ts
+++ b/client/src/app/core/menu/menu.component.ts
@@ -16,7 +16,7 @@ export class MenuComponent implements OnInit {
16 16
17 private routesPerRight = { 17 private routesPerRight = {
18 [UserRight.MANAGE_USERS]: '/admin/users', 18 [UserRight.MANAGE_USERS]: '/admin/users',
19 [UserRight.MANAGE_APPLICATION_FOLLOW]: '/admin/friends', 19 [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends',
20 [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses', 20 [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses',
21 [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist' 21 [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist'
22 } 22 }
@@ -58,7 +58,7 @@ export class MenuComponent implements OnInit {
58 58
59 const adminRights = [ 59 const adminRights = [
60 UserRight.MANAGE_USERS, 60 UserRight.MANAGE_USERS,
61 UserRight.MANAGE_APPLICATION_FOLLOW, 61 UserRight.MANAGE_SERVER_FOLLOW,
62 UserRight.MANAGE_VIDEO_ABUSES, 62 UserRight.MANAGE_VIDEO_ABUSES,
63 UserRight.MANAGE_VIDEO_BLACKLIST 63 UserRight.MANAGE_VIDEO_BLACKLIST
64 ] 64 ]
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 876c911c7..b00fb7467 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -4,13 +4,13 @@ import { badRequest } from '../../helpers'
4 4
5import { oauthClientsRouter } from './oauth-clients' 5import { oauthClientsRouter } from './oauth-clients'
6import { configRouter } from './config' 6import { configRouter } from './config'
7import { applicationRouter } from './server' 7import { serverRouter } from './server'
8import { usersRouter } from './users' 8import { usersRouter } from './users'
9import { videosRouter } from './videos' 9import { videosRouter } from './videos'
10 10
11const apiRouter = express.Router() 11const apiRouter = express.Router()
12 12
13apiRouter.use('/application', applicationRouter) 13apiRouter.use('/server', serverRouter)
14apiRouter.use('/oauth-clients', oauthClientsRouter) 14apiRouter.use('/oauth-clients', oauthClientsRouter)
15apiRouter.use('/config', configRouter) 15apiRouter.use('/config', configRouter)
16apiRouter.use('/users', usersRouter) 16apiRouter.use('/users', usersRouter)
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index e00787f02..520d4d858 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -15,9 +15,9 @@ import { ensureUserHasRight } from '../../../middlewares/user-right'
15import { followValidator } from '../../../middlewares/validators/servers' 15import { followValidator } from '../../../middlewares/validators/servers'
16import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort' 16import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort'
17 17
18const applicationFollowsRouter = express.Router() 18const serverFollowsRouter = express.Router()
19 19
20applicationFollowsRouter.get('/following', 20serverFollowsRouter.get('/following',
21 paginationValidator, 21 paginationValidator,
22 followingSortValidator, 22 followingSortValidator,
23 setFollowingSort, 23 setFollowingSort,
@@ -25,15 +25,15 @@ applicationFollowsRouter.get('/following',
25 asyncMiddleware(listFollowing) 25 asyncMiddleware(listFollowing)
26) 26)
27 27
28applicationFollowsRouter.post('/follow', 28serverFollowsRouter.post('/follow',
29 authenticate, 29 authenticate,
30 ensureUserHasRight(UserRight.MANAGE_APPLICATION_FOLLOW), 30 ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
31 followValidator, 31 followValidator,
32 setBodyHostsPort, 32 setBodyHostsPort,
33 asyncMiddleware(follow) 33 asyncMiddleware(follow)
34) 34)
35 35
36applicationFollowsRouter.get('/followers', 36serverFollowsRouter.get('/followers',
37 paginationValidator, 37 paginationValidator,
38 followersSortValidator, 38 followersSortValidator,
39 setFollowersSort, 39 setFollowersSort,
@@ -44,21 +44,21 @@ applicationFollowsRouter.get('/followers',
44// --------------------------------------------------------------------------- 44// ---------------------------------------------------------------------------
45 45
46export { 46export {
47 applicationFollowsRouter 47 serverFollowsRouter
48} 48}
49 49
50// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
51 51
52async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) { 52async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
53 const applicationAccount = await getServerAccount() 53 const serverAccount = await getServerAccount()
54 const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) 54 const resultList = await db.AccountFollow.listFollowingForApi(serverAccount.id, req.query.start, req.query.count, req.query.sort)
55 55
56 return res.json(getFormattedObjects(resultList.data, resultList.total)) 56 return res.json(getFormattedObjects(resultList.data, resultList.total))
57} 57}
58 58
59async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) { 59async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
60 const applicationAccount = await getServerAccount() 60 const serverAccount = await getServerAccount()
61 const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) 61 const resultList = await db.AccountFollow.listFollowersForApi(serverAccount.id, req.query.start, req.query.count, req.query.sort)
62 62
63 return res.json(getFormattedObjects(resultList.data, resultList.total)) 63 return res.json(getFormattedObjects(resultList.data, resultList.total))
64} 64}
diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts
index 011b971ed..8dc1a0031 100644
--- a/server/controllers/api/server/index.ts
+++ b/server/controllers/api/server/index.ts
@@ -1,12 +1,12 @@
1import * as express from 'express' 1import * as express from 'express'
2import { applicationFollowsRouter } from './follows' 2import { serverFollowsRouter } from './follows'
3 3
4const applicationRouter = express.Router() 4const serverRouter = express.Router()
5 5
6applicationRouter.use('/', applicationFollowsRouter) 6serverRouter.use('/', serverFollowsRouter)
7 7
8// --------------------------------------------------------------------------- 8// ---------------------------------------------------------------------------
9 9
10export { 10export {
11 applicationRouter 11 serverRouter
12} 12}
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index eeda8347d..f0a569410 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -322,7 +322,7 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
322if (isTestInstance() === true) { 322if (isTestInstance() === true) {
323 CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14 323 CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14
324 FRIEND_SCORE.BASE = 20 324 FRIEND_SCORE.BASE = 20
325 JOBS_FETCHING_INTERVAL = 10000 325 JOBS_FETCHING_INTERVAL = 2000
326 REMOTE_SCHEME.HTTP = 'http' 326 REMOTE_SCHEME.HTTP = 'http'
327 REMOTE_SCHEME.WS = 'ws' 327 REMOTE_SCHEME.WS = 'ws'
328 STATIC_MAX_AGE = '0' 328 STATIC_MAX_AGE = '0'
diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts
new file mode 100644
index 000000000..9ad1ca7f4
--- /dev/null
+++ b/server/tests/utils/follows.ts
@@ -0,0 +1,53 @@
1import * as request from 'supertest'
2
3import { wait } from './miscs'
4
5function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
6 const path = '/api/v1/servers/followers'
7
8 return request(url)
9 .get(path)
10 .query({ start })
11 .query({ count })
12 .query({ sort })
13 .set('Accept', 'application/json')
14 .expect(200)
15 .expect('Content-Type', /json/)
16}
17
18function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) {
19 const path = '/api/v1/servers/following'
20
21 return request(url)
22 .get(path)
23 .query({ start })
24 .query({ count })
25 .query({ sort })
26 .set('Accept', 'application/json')
27 .expect(200)
28 .expect('Content-Type', /json/)
29}
30
31async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) {
32 const path = '/api/v1/servers/follow'
33
34 const res = await request(follower)
35 .post(path)
36 .set('Accept', 'application/json')
37 .set('Authorization', 'Bearer ' + accessToken)
38 .send({ 'hosts': following })
39 .expect(expectedStatus)
40
41 // Wait request propagation
42 await wait(1000)
43
44 return res
45}
46
47// ---------------------------------------------------------------------------
48
49export {
50 getFollowersListPaginationAndSort,
51 getFollowingListPaginationAndSort,
52 follow
53}
diff --git a/server/tests/utils/pods.ts b/server/tests/utils/pods.ts
deleted file mode 100644
index 52e807e70..000000000
--- a/server/tests/utils/pods.ts
+++ /dev/null
@@ -1,103 +0,0 @@
1import * as request from 'supertest'
2
3import { wait } from './miscs'
4
5function getFriendsList (url: string) {
6 const path = '/api/v1/pods/'
7
8 return request(url)
9 .get(path)
10 .set('Accept', 'application/json')
11 .expect(200)
12 .expect('Content-Type', /json/)
13}
14
15function getPodsListPaginationAndSort (url: string, start: number, count: number, sort: string) {
16 const path = '/api/v1/pods/'
17
18 return request(url)
19 .get(path)
20 .query({ start })
21 .query({ count })
22 .query({ sort })
23 .set('Accept', 'application/json')
24 .expect(200)
25 .expect('Content-Type', /json/)
26}
27
28async function makeFriends (url: string, accessToken: string, expectedStatus = 204) {
29 // Which pod makes friends with which pod
30 const friendsMatrix = {
31 'http://localhost:9001': [
32 'localhost:9002'
33 ],
34 'http://localhost:9002': [
35 'localhost:9003'
36 ],
37 'http://localhost:9003': [
38 'localhost:9001'
39 ],
40 'http://localhost:9004': [
41 'localhost:9002'
42 ],
43 'http://localhost:9005': [
44 'localhost:9001',
45 'localhost:9004'
46 ],
47 'http://localhost:9006': [
48 'localhost:9001',
49 'localhost:9002',
50 'localhost:9003'
51 ]
52 }
53 const path = '/api/v1/pods/make-friends'
54
55 // The first pod make friend with the third
56 const res = await request(url)
57 .post(path)
58 .set('Accept', 'application/json')
59 .set('Authorization', 'Bearer ' + accessToken)
60 .send({ 'hosts': friendsMatrix[url] })
61 .expect(expectedStatus)
62
63 // Wait request propagation
64 await wait(1000)
65
66 return res
67}
68
69async function quitFriends (url: string, accessToken: string, expectedStatus = 204) {
70 const path = '/api/v1/pods/quit-friends'
71
72 // The first pod make friend with the third
73 const res = await request(url)
74 .get(path)
75 .set('Accept', 'application/json')
76 .set('Authorization', 'Bearer ' + accessToken)
77 .expect(expectedStatus)
78
79 // Wait request propagation
80 await wait(1000)
81
82 return res
83}
84
85function quitOneFriend (url: string, accessToken: string, friendId: number, expectedStatus = 204) {
86 const path = '/api/v1/pods/' + friendId
87
88 return request(url)
89 .delete(path)
90 .set('Accept', 'application/json')
91 .set('Authorization', 'Bearer ' + accessToken)
92 .expect(expectedStatus)
93}
94
95// ---------------------------------------------------------------------------
96
97export {
98 getFriendsList,
99 makeFriends,
100 quitFriends,
101 quitOneFriend,
102 getPodsListPaginationAndSort
103}
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts
index ecad69d6f..9460b668e 100644
--- a/shared/models/users/user-right.enum.ts
+++ b/shared/models/users/user-right.enum.ts
@@ -1,7 +1,7 @@
1export enum UserRight { 1export enum UserRight {
2 ALL, 2 ALL,
3 MANAGE_USERS, 3 MANAGE_USERS,
4 MANAGE_APPLICATION_FOLLOW, 4 MANAGE_SERVER_FOLLOW,
5 MANAGE_VIDEO_ABUSES, 5 MANAGE_VIDEO_ABUSES,
6 MANAGE_VIDEO_BLACKLIST, 6 MANAGE_VIDEO_BLACKLIST,
7 REMOVE_ANY_VIDEO, 7 REMOVE_ANY_VIDEO,