ApplicationFollow -> SeverFollow
authorChocobozzz <florian.bigard@gmail.com>
Thu, 16 Nov 2017 16:16:42 +0000 (17:16 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Mon, 27 Nov 2017 18:40:52 +0000 (19:40 +0100)
12 files changed:
client/src/app/+admin/follows/follows.routes.ts
client/src/app/+admin/follows/shared/follow.service.ts
client/src/app/core/menu/menu-admin.component.html
client/src/app/core/menu/menu-admin.component.ts
client/src/app/core/menu/menu.component.ts
server/controllers/api/index.ts
server/controllers/api/server/follows.ts
server/controllers/api/server/index.ts
server/initializers/constants.ts
server/tests/utils/follows.ts [new file with mode: 0644]
server/tests/utils/pods.ts [deleted file]
shared/models/users/user-right.enum.ts

index b7d44f75b11f271d3e5872eecd0627eae2f36a3d..e84c79e829ad3300f1bfc451492000d00e29c3c6 100644 (file)
@@ -13,7 +13,7 @@ export const FollowsRoutes: Routes = [
     component: FollowsComponent,
     canActivate: [ UserRightGuard ],
     data: {
-      userRight: UserRight.MANAGE_APPLICATION_FOLLOW
+      userRight: UserRight.MANAGE_SERVER_FOLLOW
     },
     children: [
       {
index 3dc91dfcae33dbc44b63e4c711a8cd68df6cab31..d64361ee31e39de12ee3c279fe8e62531f0899b2 100644 (file)
@@ -11,7 +11,7 @@ import { AccountFollow, ResultList } from '../../../../../../shared'
 
 @Injectable()
 export class FollowService {
-  private static BASE_APPLICATION_URL = API_URL + '/api/v1/application'
+  private static BASE_APPLICATION_URL = API_URL + '/api/v1/server'
 
   constructor (
     private authHttp: HttpClient,
index 99ee287c52f91572acfa734134a25c03935043d8..eb2d0d69c039d5574971ecbffe41c0541d7c40e5 100644 (file)
@@ -5,7 +5,7 @@
       List users
     </a>
 
-    <a *ngIf="hasApplicationFollowRight()" routerLink="/admin/follows" routerLinkActive="active">
+    <a *ngIf="hasServerFollowRight()" routerLink="/admin/follows" routerLinkActive="active">
       <span class="hidden-xs glyphicon glyphicon-cloud"></span>
       Manage follows
     </a>
index 88a654d1fd000ff533a6eaa7f7c26d3cea085050..466da1aee148cf26309334dccc0d181d6204cbf0 100644 (file)
@@ -15,8 +15,8 @@ export class MenuAdminComponent {
     return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
   }
 
-  hasApplicationFollowRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_APPLICATION_FOLLOW)
+  hasServerFollowRight () {
+    return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
   }
 
   hasVideoAbusesRight () {
index 872d29819bbbf343b889f6fdc897a5b85b7b7e65..d2bd71534df520999c4b46343c29a31b6606a3b7 100644 (file)
@@ -16,7 +16,7 @@ export class MenuComponent implements OnInit {
 
   private routesPerRight = {
     [UserRight.MANAGE_USERS]: '/admin/users',
-    [UserRight.MANAGE_APPLICATION_FOLLOW]: '/admin/friends',
+    [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends',
     [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses',
     [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist'
   }
@@ -58,7 +58,7 @@ export class MenuComponent implements OnInit {
 
     const adminRights = [
       UserRight.MANAGE_USERS,
-      UserRight.MANAGE_APPLICATION_FOLLOW,
+      UserRight.MANAGE_SERVER_FOLLOW,
       UserRight.MANAGE_VIDEO_ABUSES,
       UserRight.MANAGE_VIDEO_BLACKLIST
     ]
index 876c911c79c6ed232526fb5ad915fe1956d4715c..b00fb74677bf565e590b25f32f23774ee2a8f6ed 100644 (file)
@@ -4,13 +4,13 @@ import { badRequest } from '../../helpers'
 
 import { oauthClientsRouter } from './oauth-clients'
 import { configRouter } from './config'
-import { applicationRouter } from './server'
+import { serverRouter } from './server'
 import { usersRouter } from './users'
 import { videosRouter } from './videos'
 
 const apiRouter = express.Router()
 
-apiRouter.use('/application', applicationRouter)
+apiRouter.use('/server', serverRouter)
 apiRouter.use('/oauth-clients', oauthClientsRouter)
 apiRouter.use('/config', configRouter)
 apiRouter.use('/users', usersRouter)
index e00787f0252ff1e6501866f5dca96e3b7cfb8603..520d4d858536fa534e13dfcf5c2fd5c0fcb134c8 100644 (file)
@@ -15,9 +15,9 @@ import { ensureUserHasRight } from '../../../middlewares/user-right'
 import { followValidator } from '../../../middlewares/validators/servers'
 import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort'
 
-const applicationFollowsRouter = express.Router()
+const serverFollowsRouter = express.Router()
 
-applicationFollowsRouter.get('/following',
+serverFollowsRouter.get('/following',
   paginationValidator,
   followingSortValidator,
   setFollowingSort,
@@ -25,15 +25,15 @@ applicationFollowsRouter.get('/following',
   asyncMiddleware(listFollowing)
 )
 
-applicationFollowsRouter.post('/follow',
+serverFollowsRouter.post('/follow',
   authenticate,
-  ensureUserHasRight(UserRight.MANAGE_APPLICATION_FOLLOW),
+  ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
   followValidator,
   setBodyHostsPort,
   asyncMiddleware(follow)
 )
 
-applicationFollowsRouter.get('/followers',
+serverFollowsRouter.get('/followers',
   paginationValidator,
   followersSortValidator,
   setFollowersSort,
@@ -44,21 +44,21 @@ applicationFollowsRouter.get('/followers',
 // ---------------------------------------------------------------------------
 
 export {
-  applicationFollowsRouter
+  serverFollowsRouter
 }
 
 // ---------------------------------------------------------------------------
 
 async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const applicationAccount = await getServerAccount()
-  const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
+  const serverAccount = await getServerAccount()
+  const resultList = await db.AccountFollow.listFollowingForApi(serverAccount.id, req.query.start, req.query.count, req.query.sort)
 
   return res.json(getFormattedObjects(resultList.data, resultList.total))
 }
 
 async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const applicationAccount = await getServerAccount()
-  const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
+  const serverAccount = await getServerAccount()
+  const resultList = await db.AccountFollow.listFollowersForApi(serverAccount.id, req.query.start, req.query.count, req.query.sort)
 
   return res.json(getFormattedObjects(resultList.data, resultList.total))
 }
index 011b971ed63493fd523aff6fde0fc8acf2a6864c..8dc1a0031488600748a66bec4973abcca887f31f 100644 (file)
@@ -1,12 +1,12 @@
 import * as express from 'express'
-import { applicationFollowsRouter } from './follows'
+import { serverFollowsRouter } from './follows'
 
-const applicationRouter = express.Router()
+const serverRouter = express.Router()
 
-applicationRouter.use('/', applicationFollowsRouter)
+serverRouter.use('/', serverFollowsRouter)
 
 // ---------------------------------------------------------------------------
 
 export {
-  applicationRouter
+  serverRouter
 }
index eeda8347dd28b99e466f616c8e94c5297083b890..f0a569410b1f782578379d800fbbd4e7a6d2e770 100644 (file)
@@ -322,7 +322,7 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
 if (isTestInstance() === true) {
   CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14
   FRIEND_SCORE.BASE = 20
-  JOBS_FETCHING_INTERVAL = 10000
+  JOBS_FETCHING_INTERVAL = 2000
   REMOTE_SCHEME.HTTP = 'http'
   REMOTE_SCHEME.WS = 'ws'
   STATIC_MAX_AGE = '0'
diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts
new file mode 100644 (file)
index 0000000..9ad1ca7
--- /dev/null
@@ -0,0 +1,53 @@
+import * as request from 'supertest'
+
+import { wait } from './miscs'
+
+function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
+  const path = '/api/v1/servers/followers'
+
+  return request(url)
+    .get(path)
+    .query({ start })
+    .query({ count })
+    .query({ sort })
+    .set('Accept', 'application/json')
+    .expect(200)
+    .expect('Content-Type', /json/)
+}
+
+function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) {
+  const path = '/api/v1/servers/following'
+
+  return request(url)
+    .get(path)
+    .query({ start })
+    .query({ count })
+    .query({ sort })
+    .set('Accept', 'application/json')
+    .expect(200)
+    .expect('Content-Type', /json/)
+}
+
+async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) {
+  const path = '/api/v1/servers/follow'
+
+  const res = await request(follower)
+    .post(path)
+    .set('Accept', 'application/json')
+    .set('Authorization', 'Bearer ' + accessToken)
+    .send({ 'hosts': following })
+    .expect(expectedStatus)
+
+  // Wait request propagation
+  await wait(1000)
+
+  return res
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+  getFollowersListPaginationAndSort,
+  getFollowingListPaginationAndSort,
+  follow
+}
diff --git a/server/tests/utils/pods.ts b/server/tests/utils/pods.ts
deleted file mode 100644 (file)
index 52e807e..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-import * as request from 'supertest'
-
-import { wait } from './miscs'
-
-function getFriendsList (url: string) {
-  const path = '/api/v1/pods/'
-
-  return request(url)
-          .get(path)
-          .set('Accept', 'application/json')
-          .expect(200)
-          .expect('Content-Type', /json/)
-}
-
-function getPodsListPaginationAndSort (url: string, start: number, count: number, sort: string) {
-  const path = '/api/v1/pods/'
-
-  return request(url)
-    .get(path)
-    .query({ start })
-    .query({ count })
-    .query({ sort })
-    .set('Accept', 'application/json')
-    .expect(200)
-    .expect('Content-Type', /json/)
-}
-
-async function makeFriends (url: string, accessToken: string, expectedStatus = 204) {
-  // Which pod makes friends with which pod
-  const friendsMatrix = {
-    'http://localhost:9001': [
-      'localhost:9002'
-    ],
-    'http://localhost:9002': [
-      'localhost:9003'
-    ],
-    'http://localhost:9003': [
-      'localhost:9001'
-    ],
-    'http://localhost:9004': [
-      'localhost:9002'
-    ],
-    'http://localhost:9005': [
-      'localhost:9001',
-      'localhost:9004'
-    ],
-    'http://localhost:9006': [
-      'localhost:9001',
-      'localhost:9002',
-      'localhost:9003'
-    ]
-  }
-  const path = '/api/v1/pods/make-friends'
-
-  // The first pod make friend with the third
-  const res = await request(url)
-                      .post(path)
-                      .set('Accept', 'application/json')
-                      .set('Authorization', 'Bearer ' + accessToken)
-                      .send({ 'hosts': friendsMatrix[url] })
-                      .expect(expectedStatus)
-
-  // Wait request propagation
-  await wait(1000)
-
-  return res
-}
-
-async function quitFriends (url: string, accessToken: string, expectedStatus = 204) {
-  const path = '/api/v1/pods/quit-friends'
-
-  // The first pod make friend with the third
-  const res = await request(url)
-                      .get(path)
-                      .set('Accept', 'application/json')
-                      .set('Authorization', 'Bearer ' + accessToken)
-                      .expect(expectedStatus)
-
-  // Wait request propagation
-  await wait(1000)
-
-  return res
-}
-
-function quitOneFriend (url: string, accessToken: string, friendId: number, expectedStatus = 204) {
-  const path = '/api/v1/pods/' + friendId
-
-  return request(url)
-          .delete(path)
-          .set('Accept', 'application/json')
-          .set('Authorization', 'Bearer ' + accessToken)
-          .expect(expectedStatus)
-}
-
-// ---------------------------------------------------------------------------
-
-export {
-  getFriendsList,
-  makeFriends,
-  quitFriends,
-  quitOneFriend,
-  getPodsListPaginationAndSort
-}
index ecad69d6f6c8ae8c943234d2c589d3b2acbda9f5..9460b668ee438e7994a2157ec088d5ff540e078d 100644 (file)
@@ -1,7 +1,7 @@
 export enum UserRight {
   ALL,
   MANAGE_USERS,
-  MANAGE_APPLICATION_FOLLOW,
+  MANAGE_SERVER_FOLLOW,
   MANAGE_VIDEO_ABUSES,
   MANAGE_VIDEO_BLACKLIST,
   REMOVE_ANY_VIDEO,