Only use account name in routes
authorChocobozzz <me@florianbigard.com>
Fri, 25 May 2018 07:57:16 +0000 (09:57 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 25 May 2018 08:41:07 +0000 (10:41 +0200)
28 files changed:
client/src/app/+accounts/account-video-channels/account-video-channels.component.ts
client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts
client/src/app/+video-channels/video-channels.component.html
client/src/app/menu/menu.component.html
client/src/app/shared/account/account.model.ts
client/src/app/shared/users/user.model.ts
client/src/app/shared/video-channel/video-channel.service.ts
client/src/app/shared/video/video-details.model.ts
client/src/app/shared/video/video-miniature.component.html
client/src/app/shared/video/video.service.ts
client/src/app/videos/+video-edit/video-update.component.ts
client/src/app/videos/+video-watch/video-watch.component.html
server/controllers/api/accounts.ts
server/controllers/services.ts
server/helpers/custom-validators/accounts.ts
server/middlewares/validators/account.ts
server/middlewares/validators/video-channels.ts
server/tests/api/check-params/accounts.ts
server/tests/api/check-params/video-channels.ts
server/tests/api/check-params/videos.ts
server/tests/api/users/users-multiple-servers.ts
server/tests/api/videos/video-channels.ts
server/tests/api/videos/video-nsfw.ts
server/tests/utils/users/accounts.ts
server/tests/utils/videos/video-channels.ts
server/tests/utils/videos/videos.ts
support/doc/api/html/index.html
support/doc/api/openapi.yaml

index 0852c4bb75b1e5307fe4221a59f6603328449385..a6e6dd656bbf73ccbbce65efee233e67eb8d6fff 100644 (file)
@@ -26,7 +26,7 @@ export class AccountVideoChannelsComponent implements OnInit {
     this.accountService.accountLoaded
         .pipe(
           tap(account => this.account = account),
-          flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)),
+          flatMap(account => this.videoChannelService.listAccountVideoChannels(account)),
           map(res => res.data)
         )
         .subscribe(videoChannels => this.videoChannels = videoChannels)
index 7abf48826b7d4dc79ca9014f1b5ee3b647b3e944..20c8798d15c340f5f6aa11fa1468aaca6facc277 100644 (file)
@@ -52,7 +52,7 @@ export class MyAccountVideoChannelsComponent implements OnInit {
 
   private loadVideoChannels () {
     this.authService.userInformationLoaded
-        .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account.id)))
+        .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account)))
         .subscribe(res => this.videoChannels = res.data)
   }
 }
index da0d76acfe2891462c4aad4a4255aaf760c86930..6b25d16ab7cf6ca2d21546acd168a8969810298a 100644 (file)
@@ -10,7 +10,7 @@
         </div>
         <div class="actor-followers">{{ videoChannel.followersCount }} subscribers</div>
 
-        <a [routerLink]="[ '/accounts', videoChannel.ownerAccount.id ]" title="Go the owner account page" class="actor-owner">
+        <a [routerLink]="[ '/accounts', videoChannel.ownerBy ]" title="Go the owner account page" class="actor-owner">
           <span>Created by {{ videoChannel.ownerBy }}</span>
           <img [src]="videoChannel.ownerAvatarUrl" alt="Owner account avatar" />
         </a>
index 6a2a495a28438ed1ed4b36bc23e583e12c0caf0f..1a95477b7672ca30cf5ce900965c02c2d7f8de37 100644 (file)
@@ -14,7 +14,7 @@
 
       <ul *dropdownMenu class="dropdown-menu">
         <li>
-          <a i18n [routerLink]="[ '/accounts', user.account?.id ]" class="dropdown-item" title="My public profile">
+          <a i18n [routerLink]="[ '/accounts', user.account?.nameWithHost ]" class="dropdown-item" title="My public profile">
            My public profile
           </a>
 
index 6a3c6451c420fe0bee8690a4e04149b177987d5d..5058e372fd9505ecf99fe1d1c191417d99285b92 100644 (file)
@@ -4,11 +4,13 @@ import { Actor } from '../actor/actor.model'
 export class Account extends Actor implements ServerAccount {
   displayName: string
   description: string
+  nameWithHost: string
 
   constructor (hash: ServerAccount) {
     super(hash)
 
     this.displayName = hash.displayName
     this.description = hash.description
+    this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
   }
 }
index d4551de894b699fa7f358cbeda1bdae01fb17888..b4be2270f8c82818db140ed7a3731d9f752f2388 100644 (file)
@@ -1,6 +1,14 @@
-import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
+import {
+  Account as AccountServerModel,
+  hasUserRight,
+  User as UserServerModel,
+  UserRight,
+  UserRole,
+  VideoChannel
+} from '../../../../../shared'
 import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
 import { Actor } from '@app/shared/actor/actor.model'
+import { Account } from '@app/shared/account/account.model'
 
 export type UserConstructorHash = {
   id: number,
@@ -11,7 +19,7 @@ export type UserConstructorHash = {
   nsfwPolicy?: NSFWPolicyType,
   autoPlayVideo?: boolean,
   createdAt?: Date,
-  account?: Account,
+  account?: AccountServerModel,
   videoChannels?: VideoChannel[]
 }
 export class User implements UserServerModel {
@@ -32,7 +40,10 @@ export class User implements UserServerModel {
     this.username = hash.username
     this.email = hash.email
     this.role = hash.role
-    this.account = hash.account
+
+    if (hash.account !== undefined) {
+      this.account = new Account(hash.account)
+    }
 
     if (hash.videoChannels !== undefined) {
       this.videoChannels = hash.videoChannels
@@ -66,6 +77,10 @@ export class User implements UserServerModel {
       this[key] = obj[key]
     }
 
+    if (obj.account !== undefined) {
+      this.account = new Account(obj.account)
+    }
+
     this.updateComputedAttributes()
   }
 
index e1e3bf6979c8b60d9ca78f9f23d615398945a979..55e4c2a312908ffbb17ed296a712ceac1a18cf66 100644 (file)
@@ -8,6 +8,7 @@ import { AccountService } from '../account/account.service'
 import { ResultList } from '../../../../../shared'
 import { VideoChannel } from './video-channel.model'
 import { environment } from '../../../environments/environment'
+import { Account } from '@app/shared/account/account.model'
 
 @Injectable()
 export class VideoChannelService {
@@ -29,8 +30,8 @@ export class VideoChannelService {
                )
   }
 
-  listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {
-    return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')
+  listAccountVideoChannels (account: Account): Observable<ResultList<VideoChannel>> {
+    return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels')
                .pipe(
                  map(res => this.extractVideoChannels(res)),
                  catchError((res) => this.restExtractor.handleError(res))
index 5397aa37f7ed9813a3e7454c17bca1881e4340cf..5fc55fca60de1f68caa6919b4ddb9a9fd318c30c 100644 (file)
@@ -1,7 +1,7 @@
 import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared'
-import { Account } from '../../../../../shared/models/actors'
 import { AuthUser } from '../../core'
 import { Video } from '../../shared/video/video.model'
+import { Account } from '@app/shared/account/account.model'
 
 export class VideoDetails extends Video implements VideoDetailsServerModel {
   descriptionPath: string
@@ -21,7 +21,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
     this.descriptionPath = hash.descriptionPath
     this.files = hash.files
     this.channel = hash.channel
-    this.account = hash.account
+    this.account = new Account(hash.account)
     this.tags = hash.tags
     this.support = hash.support
     this.commentsEnabled = hash.commentsEnabled
index 1725e9f5cbd73f00c218bc1e42d901df294db98d..09ce0ef7f18ba96c3a4d2d61fe68aea8f7dba01f 100644 (file)
@@ -6,10 +6,10 @@
       class="video-miniature-name"
       [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }"
     >
-        {{ video.name }}
+      {{ video.name }}
     </a>
 
     <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
-    <a class="video-miniature-account" [routerLink]="[ '/accounts', video.account.id ]">{{ video.by }}</a>
+    <a class="video-miniature-account" [routerLink]="[ '/accounts', video.by ]">{{ video.by }}</a>
   </div>
 </div>
index 5b8e2467a6c5eb8e9d29f47b13b6a1992b4c7324..d1e32faebd55719de1a4131ba7bb0f149bb302aa 100644 (file)
@@ -120,7 +120,7 @@ export class VideoService {
     params = this.restService.addRestGetParams(params, pagination, sort)
 
     return this.authHttp
-               .get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params })
+               .get(AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/videos', { params })
                .pipe(
                  map(this.extractVideos),
                  catchError(res => this.restExtractor.handleError(res))
index 00c2ed3f11bc69c5cc2b6d07933fdf76084de4cf..339da1bf472fe41823dce633ee49319a430cfce0 100644 (file)
@@ -63,7 +63,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
           }),
           switchMap(video => {
             return this.videoChannelService
-                       .listAccountVideoChannels(video.account.id)
+                       .listAccountVideoChannels(video.account)
                        .pipe(
                          map(result => result.data),
                          map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName }))),
index 212bfdd8cc2afd1ae158dbd08e1fb25027d785dc..583a97562655fc3fbd7e68ed52e2ac585403bcee 100644 (file)
@@ -25,7 +25,7 @@
           </div>
 
           <div class="video-info-by">
-            <a [routerLink]="[ '/accounts', video.account.id ]" title="Go the account page">
+            <a [routerLink]="[ '/accounts', video.by ]" title="Go the account page">
               <span>By {{ video.by }}</span>
               <img [src]="video.accountAvatarUrl" alt="Account avatar" />
             </a>
index ccae0436b12cc1f49f9bc0e10fe971ef137f1bce..8e937276cde72ac2af7499bf010a460597dcf2a1 100644 (file)
@@ -8,7 +8,7 @@ import {
   setDefaultPagination,
   setDefaultSort
 } from '../../middlewares'
-import { accountsGetValidator, accountsSortValidator, videosSortValidator } from '../../middlewares/validators'
+import { accountsNameWithHostGetValidator, accountsSortValidator, videosSortValidator } from '../../middlewares/validators'
 import { AccountModel } from '../../models/account/account'
 import { VideoModel } from '../../models/video/video'
 import { isNSFWHidden } from '../../helpers/express-utils'
@@ -24,13 +24,13 @@ accountsRouter.get('/',
   asyncMiddleware(listAccounts)
 )
 
-accountsRouter.get('/:id',
-  asyncMiddleware(accountsGetValidator),
+accountsRouter.get('/:accountName',
+  asyncMiddleware(accountsNameWithHostGetValidator),
   getAccount
 )
 
-accountsRouter.get('/:id/videos',
-  asyncMiddleware(accountsGetValidator),
+accountsRouter.get('/:accountName/videos',
+  asyncMiddleware(accountsNameWithHostGetValidator),
   paginationValidator,
   videosSortValidator,
   setDefaultSort,
@@ -39,7 +39,7 @@ accountsRouter.get('/:id/videos',
   asyncMiddleware(listAccountVideos)
 )
 
-accountsRouter.get('/:accountId/video-channels',
+accountsRouter.get('/:accountName/video-channels',
   asyncMiddleware(listVideoAccountChannelsValidator),
   asyncMiddleware(listVideoAccountChannels)
 )
index c272edccd5196256d93089544d7388e2f11cfd90..a58a5b8cf2b49a068de56f2480b2e39271198c4c 100644 (file)
@@ -10,7 +10,7 @@ servicesRouter.use('/oembed',
   asyncMiddleware(oembedValidator),
   generateOEmbed
 )
-servicesRouter.use('/redirect/accounts/:nameWithHost',
+servicesRouter.use('/redirect/accounts/:accountName',
   asyncMiddleware(accountsNameWithHostGetValidator),
   redirectToAccountUrl
 )
index 00dea9039d53f0a3e9a26c8a8060f1ce58de363c..0607d661c2c41d6d586362e7c0aecb2acd8cfa08 100644 (file)
@@ -5,6 +5,7 @@ import * as validator from 'validator'
 import { AccountModel } from '../../models/account/account'
 import { isUserDescriptionValid, isUserUsernameValid } from './users'
 import { exists } from './misc'
+import { CONFIG } from '../../initializers'
 
 function isAccountNameValid (value: string) {
   return isUserUsernameValid(value)
@@ -40,7 +41,7 @@ function isAccountNameWithHostExist (nameWithDomain: string, res: Response, send
   const [ accountName, host ] = nameWithDomain.split('@')
 
   let promise: Bluebird<AccountModel>
-  if (!host) promise = AccountModel.loadLocalByName(accountName)
+  if (!host || host === CONFIG.WEBSERVER.HOST) promise = AccountModel.loadLocalByName(accountName)
   else promise = AccountModel.loadLocalByNameAndHost(accountName, host)
 
   return isAccountExist(promise, res, sendNotFound)
index c01e742da3b478bf5ed42ca00505c71da9e56294..b3a51e631a5ff255af4d1599149d254bb4a31511 100644 (file)
@@ -1,15 +1,8 @@
 import * as express from 'express'
 import { param } from 'express-validator/check'
-import {
-  isAccountIdExist,
-  isAccountIdValid,
-  isAccountNameValid,
-  isAccountNameWithHostExist,
-  isLocalAccountNameExist
-} from '../../helpers/custom-validators/accounts'
+import { isAccountNameValid, isAccountNameWithHostExist, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
 import { logger } from '../../helpers/logger'
 import { areValidationErrors } from './utils'
-import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
 
 const localAccountValidator = [
   param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
@@ -24,32 +17,14 @@ const localAccountValidator = [
   }
 ]
 
-const accountsGetValidator = [
-  param('id').custom(isAccountIdValid).withMessage('Should have a valid id/uuid/name/name with host'),
-
-  async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking accountsGetValidator parameters', { parameters: req.params })
-
-    if (areValidationErrors(req, res)) return
-
-    let accountFetched = false
-    if (isIdOrUUIDValid(req.params.id)) accountFetched = await isAccountIdExist(req.params.id, res, false)
-    if (!accountFetched) accountFetched = await isAccountNameWithHostExist(req.params.id, res, true)
-
-    if (!accountFetched) return
-
-    return next()
-  }
-]
-
 const accountsNameWithHostGetValidator = [
-  param('nameWithHost').exists().withMessage('Should have an account name with host'),
+  param('accountName').exists().withMessage('Should have an account name with host'),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
     logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isAccountNameWithHostExist(req.params.nameWithHost, res)) return
+    if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
 
     return next()
   }
@@ -59,6 +34,5 @@ const accountsNameWithHostGetValidator = [
 
 export {
   localAccountValidator,
-  accountsGetValidator,
   accountsNameWithHostGetValidator
 }
index 92c0de419eec0256a5862a22c4ada653543080ac..a5be5f1146b24ba59080fed0672d085be155d7b8 100644 (file)
@@ -1,7 +1,7 @@
 import * as express from 'express'
 import { body, param } from 'express-validator/check'
 import { UserRight } from '../../../shared'
-import { isAccountIdExist } from '../../helpers/custom-validators/accounts'
+import { isAccountIdExist, isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
 import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
 import {
   isVideoChannelDescriptionValid,
@@ -15,13 +15,13 @@ import { VideoChannelModel } from '../../models/video/video-channel'
 import { areValidationErrors } from './utils'
 
 const listVideoAccountChannelsValidator = [
-  param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'),
+  param('accountName').exists().withMessage('Should have a valid account name'),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
     logger.debug('Checking listVideoAccountChannelsValidator parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isAccountIdExist(req.params.accountId, res)) return
+    if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
 
     return next()
   }
index 50dc0804efa25cdaaff59786e1775b18e94cf241..9e0b1e35c609df0d00c4b565e5a5247e2681d3a4 100644 (file)
@@ -35,8 +35,8 @@ describe('Test users API validators', function () {
   })
 
   describe('When getting an account', function () {
-    it('Should return 404 with a non existing id', async function () {
-      await getAccount(server.url, 4545454, 404)
+    it('Should return 404 with a non existing name', async function () {
+      await getAccount(server.url, 'arfaze', 404)
     })
   })
 
index 56b990be6f257d89a117c6db37bfddfbb8e8c4ad..5080af2c964db1d01e3a7c4f9e4e3bd698374ca8 100644 (file)
@@ -7,7 +7,8 @@ import {
   createUser,
   deleteVideoChannel,
   flushTests,
-  getAccountVideoChannelsList, getMyUserInformation,
+  getAccountVideoChannelsList,
+  getMyUserInformation,
   getVideoChannelsList,
   immutableAssign,
   killallServers,
@@ -20,7 +21,6 @@ import {
   userLogin
 } from '../../utils'
 import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
-import { getAccountsList } from '../../utils/users/accounts'
 import { User } from '../../../../shared/models/users'
 
 const expect = chai.expect
@@ -74,12 +74,8 @@ describe('Test video channels API validator', function () {
   })
 
   describe('When listing account video channels', function () {
-    it('Should fail with bad account', async function () {
-      await getAccountVideoChannelsList(server.url, 'hello', 400)
-    })
-
     it('Should fail with a unknown account', async function () {
-      await getAccountVideoChannelsList(server.url, 154, 404)
+      await getAccountVideoChannelsList(server.url, 'unknown', 404)
     })
   })
 
index c81e9752ef96f1bac39617531b35c2c8f0dcf164..7b40b91e708dd10ce117504a3b98ef21e6ae5094 100644 (file)
@@ -18,7 +18,7 @@ describe('Test videos API validator', function () {
   const path = '/api/v1/videos/'
   let server: ServerInfo
   let userAccessToken = ''
-  let accountUUID: string
+  let accountName: string
   let channelId: number
   let channelUUID: string
   let videoId
@@ -43,7 +43,7 @@ describe('Test videos API validator', function () {
       const res = await getMyUserInformation(server.url, server.accessToken)
       channelId = res.body.videoChannels[ 0 ].id
       channelUUID = res.body.videoChannels[ 0 ].uuid
-      accountUUID = res.body.account.uuid
+      accountName = res.body.account.name + '@' + res.body.account.host
     }
   })
 
@@ -116,7 +116,7 @@ describe('Test videos API validator', function () {
     let path: string
 
     before(async function () {
-      path = '/api/v1/accounts/' + accountUUID + '/videos'
+      path = '/api/v1/accounts/' + accountName + '/videos'
     })
 
     it('Should fail with a bad start pagination', async function () {
index 8b9b63348cc9d6f9662341d3469f51886d3a1c16..0e1e6c97db3975b5e52dee8b6f7723f40cd9be28 100644 (file)
@@ -26,7 +26,7 @@ const expect = chai.expect
 describe('Test users with multiple servers', function () {
   let servers: ServerInfo[] = []
   let user: User
-  let userAccountUUID: string
+  let userAccountName: string
   let userVideoChannelUUID: string
   let userId: number
   let videoUUID: string
@@ -56,12 +56,15 @@ describe('Test users with multiple servers', function () {
         password: 'password'
       }
       const res = await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, user.username, user.password)
-      userAccountUUID = res.body.user.account.uuid
       userId = res.body.user.id
-
       userAccessToken = await userLogin(servers[ 0 ], user)
     }
 
+    {
+      const res = await getMyUserInformation(servers[0].url, userAccessToken)
+      userAccountName = res.body.account.name + '@' + res.body.account.host
+    }
+
     {
       const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken)
       const user: User = res.body
@@ -135,7 +138,7 @@ describe('Test users with multiple servers', function () {
       const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account
       expect(rootServer1List).not.to.be.undefined
 
-      const resAccount = await getAccount(server.url, rootServer1List.id)
+      const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
       const rootServer1Get = resAccount.body as Account
       expect(rootServer1Get.name).to.equal('root')
       expect(rootServer1Get.host).to.equal('localhost:9001')
@@ -148,7 +151,7 @@ describe('Test users with multiple servers', function () {
 
   it('Should list account videos', async function () {
     for (const server of servers) {
-      const res = await getAccountVideos(server.url, server.accessToken, userAccountUUID, 0, 5)
+      const res = await getAccountVideos(server.url, server.accessToken, userAccountName, 0, 5)
 
       expect(res.body.total).to.equal(1)
       expect(res.body.data).to.be.an('array')
@@ -193,7 +196,7 @@ describe('Test users with multiple servers', function () {
 
   it('Should not have actor files', async () => {
     for (const server of servers) {
-      await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)
+      await checkActorFilesWereRemoved(userAccountName, server.serverNumber)
       await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)
     }
   })
index 35c418f7c65abf342fc9d60f9d8fd4ac23b05fd5..7ae505fd78b046da9218822918e9afa71be3673f 100644 (file)
@@ -17,7 +17,6 @@ import {
   setAccessTokensToServers,
   updateVideoChannel
 } from '../../utils/index'
-import { getAccountsList } from '../../utils/users/accounts'
 
 const expect = chai.expect
 
@@ -99,7 +98,7 @@ describe('Test video channels', function () {
   })
 
   it('Should have two video channels when getting account channels on server 1', async function () {
-    const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid)
+    const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host)
     expect(res.body.total).to.equal(2)
     expect(res.body.data).to.be.an('array')
     expect(res.body.data).to.have.lengthOf(2)
@@ -112,7 +111,7 @@ describe('Test video channels', function () {
   })
 
   it('Should have one video channel when getting account channels on server 2', async function () {
-    const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid)
+    const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host)
     expect(res.body.total).to.equal(1)
     expect(res.body.data).to.be.an('array')
     expect(res.body.data).to.have.lengthOf(1)
index b8c85f45b339d9e764c72f13d338fdebfe2e7424..a8f1525610144f4a773879b5c21161fe44038069 100644 (file)
@@ -32,13 +32,13 @@ describe('Test video NSFW policy', function () {
       .then(res => {
         const user: User = res.body
         const videoChannelUUID = user.videoChannels[0].uuid
-        const accountUUID = user.account.uuid
+        const accountName = user.account.name + '@' + user.account.host
 
         if (token) {
           return Promise.all([
             getVideosListWithToken(server.url, token),
             searchVideoWithToken(server.url, 'n', token),
-            getAccountVideos(server.url, token, accountUUID, 0, 5),
+            getAccountVideos(server.url, token, accountName, 0, 5),
             getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5)
           ])
         }
@@ -46,7 +46,7 @@ describe('Test video NSFW policy', function () {
         return Promise.all([
           getVideosList(server.url),
           searchVideo(server.url, 'n'),
-          getAccountVideos(server.url, undefined, accountUUID, 0, 5),
+          getAccountVideos(server.url, undefined, accountName, 0, 5),
           getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5)
         ])
       })
index a5c13c319a7d11bda561d6ebe9c05e3b2dd494d6..30b3c54f8ec29b2c2cdc72e401968cb8ac1e34bd 100644 (file)
@@ -19,8 +19,8 @@ function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected =
   })
 }
 
-function getAccount (url: string, accountId: number | string, statusCodeExpected = 200) {
-  const path = '/api/v1/accounts/' + accountId
+function getAccount (url: string, accountName: string, statusCodeExpected = 200) {
+  const path = '/api/v1/accounts/' + accountName
 
   return makeGetRequest({
     url,
index 021c4c420c62ab92d1a8b996a349c61badda1b73..a064598f47a235e890dbf3fdbe314641e47402b6 100644 (file)
@@ -16,8 +16,8 @@ function getVideoChannelsList (url: string, start: number, count: number, sort?:
             .expect('Content-Type', /json/)
 }
 
-function getAccountVideoChannelsList (url: string, accountId: number | string, specialStatus = 200) {
-  const path = '/api/v1/accounts/' + accountId + '/video-channels'
+function getAccountVideoChannelsList (url: string, accountName: string, specialStatus = 200) {
+  const path = '/api/v1/accounts/' + accountName + '/video-channels'
 
   return request(url)
     .get(path)
index 07c4ffc7769cb8c779baf59158375858e9e9dd35..46fa5f79d357217654864cdc3ee265975d6a7ac0 100644 (file)
@@ -167,8 +167,8 @@ function getMyVideos (url: string, accessToken: string, start: number, count: nu
     .expect('Content-Type', /json/)
 }
 
-function getAccountVideos (url: string, accessToken: string, accountId: number | string, start: number, count: number, sort?: string) {
-  const path = '/api/v1/accounts/' + accountId + '/videos'
+function getAccountVideos (url: string, accessToken: string, accountName: string, start: number, count: number, sort?: string) {
+  const path = '/api/v1/accounts/' + accountName + '/videos'
 
   return makeGetRequest({
     url,
index d41fc391325b0d890dd096ea79338a5cfbd20e09..b75a2a8ba5fb431e1bf87a238c3a5b281f6c80f9 100644 (file)
             <a href="#tag-Accounts">Accounts</a>
             <ul>
               <li>
-                <a href="#operation--accounts--id--get"> GET /accounts/{id} </a>
+                <a href="#operation--accounts--name--get"> GET /accounts/{name} </a>
               </li>
               <li>
-                <a href="#operation--accounts--id--videos-get"> GET /accounts/{id}/videos </a>
+                <a href="#operation--accounts--name--videos-get"> GET /accounts/{name}/videos </a>
               </li>
               <li>
                 <a href="#operation--accounts-get"> GET /accounts </a>
                 <a href="#operation--video-channels--id--videos-get"> GET /video-channels/{id}/videos </a>
               </li>
               <li>
-                <a href="#operation--accounts--accountId--video-channels-get"> GET /accounts/{accountId}/video-channels </a>
+                <a href="#operation--accounts--name--video-channels-get"> GET /accounts/{name}/video-channels </a>
               </li>
             </ul>
           </section>
             </div>
           </div>
           <h1 id="tag-Accounts" class="swagger-summary-tag" data-traverse-target="tag-Accounts">Accounts</h1>
-          <div id="operation--accounts--id--get" class="operation panel" data-traverse-target="operation--accounts--id--get">
+          <div id="operation--accounts--name--get" class="operation panel" data-traverse-target="operation--accounts--name--get">
             <!-- <section class="operation-tags row"> -->
             <!-- <div class="doc-copy"> -->
             <div class="operation-tags">
             <h2 class="operation-title">
               <span class="operation-name">
                 <span class="operation-name">GET</span>
-                <span class="operation-path">/accounts/{id}</span>
+                <span class="operation-path">/accounts/{name}</span>
               </span>
             </h2>
             <div class="doc-row">
                 <section class="swagger-request-params">
                   <div class="prop-row prop-group">
                     <div class="prop-name">
-                      <div class="prop-title">id</div>
+                      <div class="prop-title">name</div>
                       <span class="json-property-required"></span>
                       <div class="prop-subtitle"> in path </div>
                       <div class="prop-subtitle">
                       </div>
                     </div>
                     <div class="prop-value">
-                      <p>The id of the account</p>
+                      <p>The name of the account (chocobozzz or
+                        <a href="mailto:chocobozzz@peertube.cpy.re">chocobozzz@peertube.cpy.re</a> for example)</p>
                     </div>
                   </div>
                   <div class="prop-row prop-group">
               </div>
             </div>
           </div>
-          <div id="operation--accounts--id--videos-get" class="operation panel" data-traverse-target="operation--accounts--id--videos-get">
+          <div id="operation--accounts--name--videos-get" class="operation panel" data-traverse-target="operation--accounts--name--videos-get">
             <!-- <section class="operation-tags row"> -->
             <!-- <div class="doc-copy"> -->
             <div class="operation-tags">
             <h2 class="operation-title">
               <span class="operation-name">
                 <span class="operation-name">GET</span>
-                <span class="operation-path">/accounts/{id}/videos</span>
+                <span class="operation-path">/accounts/{name}/videos</span>
               </span>
             </h2>
             <div class="doc-row">
                 <section class="swagger-request-params">
                   <div class="prop-row prop-group">
                     <div class="prop-name">
-                      <div class="prop-title">id</div>
+                      <div class="prop-title">name</div>
                       <span class="json-property-required"></span>
                       <div class="prop-subtitle"> in path </div>
                       <div class="prop-subtitle">
                       </div>
                     </div>
                     <div class="prop-value">
-                      <p>The id of the account</p>
+                      <p>The name of the account (chocobozzz or
+                        <a href="mailto:chocobozzz@peertube.cpy.re">chocobozzz@peertube.cpy.re</a> for example)</p>
                     </div>
                   </div>
                 </section>
               </div>
             </div>
           </div>
-          <div id="operation--accounts--accountId--video-channels-get" class="operation panel" data-traverse-target="operation--accounts--accountId--video-channels-get">
+          <div id="operation--accounts--name--video-channels-get" class="operation panel" data-traverse-target="operation--accounts--name--video-channels-get">
             <!-- <section class="operation-tags row"> -->
             <!-- <div class="doc-copy"> -->
             <div class="operation-tags">
             <h2 class="operation-title">
               <span class="operation-name">
                 <span class="operation-name">GET</span>
-                <span class="operation-path">/accounts/{accountId}/video-channels</span>
+                <span class="operation-path">/accounts/{name}/video-channels</span>
               </span>
             </h2>
             <div class="doc-row">
                 <section class="swagger-request-params">
                   <div class="prop-row prop-group">
                     <div class="prop-name">
-                      <div class="prop-title">accountId</div>
+                      <div class="prop-title">name</div>
                       <span class="json-property-required"></span>
                       <div class="prop-subtitle"> in path </div>
                       <div class="prop-subtitle">
                       </div>
                     </div>
                     <div class="prop-value">
-                      <p>The account id </p>
+                      <p>The name of the account (chocobozzz or
+                        <a href="mailto:chocobozzz@peertube.cpy.re">chocobozzz@peertube.cpy.re</a> for example)</p>
                     </div>
                   </div>
                 </section>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="name">
+                            <span class="json-property-name">name:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="displayName">
+                            <span class="json-property-name">displayName:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="url">
+                            <span class="json-property-name">url:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="host">
+                            <span class="json-property-name">host:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="avatar">
+                            <span class="json-property-name">avatar:</span>
+                            <span class="json-property-type">
+                              <span class="">
+                                <a class="json-schema-ref" href="#/definitions/Avatar">Avatar</a>
+                              </span>
+                            </span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="id">
+                            <span class="json-property-name">id:</span>
+                            <span class="json-property-type">number</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="name">
+                            <span class="json-property-name">name:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="uuid">
+                            <span class="json-property-name">uuid:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="url">
+                            <span class="json-property-name">url:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                     <dt data-property-name="createdAt">
                       <span class="json-property-name">createdAt:</span>
                       <span class="json-property-type">string</span>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="id">
+                            <span class="json-property-name">id:</span>
+                            <span class="json-property-type">number</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="uuid">
+                            <span class="json-property-name">uuid:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
                       </span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-array-items">
+                        <span class="json-property-type">
+                          <span class="">
+                            <a class="json-schema-ref" href="#/definitions/VideoCommentThreadTree">VideoCommentThreadTree</a>
+                          </span>
+                        </span>
+                        <span class="json-property-range" title="Value limits"></span>
+                        <div class="json-inner-schema"> </div>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
                       </span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-array-items">
+                        <span class="json-property-type">
+                          <span class="">
+                            <a class="json-schema-ref" href="#/definitions/VideoChannel">VideoChannel</a>
+                          </span>
+                        </span>
+                        <span class="json-property-range" title="Value limits"></span>
+                        <div class="json-inner-schema"> </div>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="allowed">
+                            <span class="json-property-name">allowed:</span>
+                            <span class="json-property-type">boolean</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                     <dt data-property-name="transcoding">
                       <span class="json-property-name">transcoding:</span>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="enabledResolutions">
+                            <span class="json-property-name">enabledResolutions:</span>
+                            <span class="json-property-type">number[]</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt class="json-inner-schema">
+                            <section class="json-schema-array-items">
+                              <span class="json-property-type">number</span>
+                              <span class="json-property-range" title="Value limits"></span>
+                              <div class="json-inner-schema"> </div>
+                            </section>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                     <dt data-property-name="avatar">
                       <span class="json-property-name">avatar:</span>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="file">
+                            <span class="json-property-name">file:</span>
+                            <span class="json-property-type">object</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt class="json-inner-schema">
+                            <section class="json-schema-properties">
+                              <dl>
+                                <dt data-property-name="size">
+                                  <span class="json-property-name">size:</span>
+                                  <span class="json-property-type">object</span>
+                                  <span class="json-property-range" title="Value limits"></span>
+                                </dt>
+                                <dt class="json-inner-schema">
+                                  <section class="json-schema-properties">
+                                    <dl>
+                                      <dt data-property-name="max">
+                                        <span class="json-property-name">max:</span>
+                                        <span class="json-property-type">number</span>
+                                        <span class="json-property-range" title="Value limits"></span>
+                                      </dt>
+                                    </dl>
+                                  </section>
+                                </dt>
+                              </dl>
+                            </section>
+                          </dt>
+                          <dt data-property-name="extensions">
+                            <span class="json-property-name">extensions:</span>
+                            <span class="json-property-type">string[]</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt class="json-inner-schema">
+                            <section class="json-schema-array-items">
+                              <span class="json-property-type">string</span>
+                              <span class="json-property-range" title="Value limits"></span>
+                              <div class="json-inner-schema"> </div>
+                            </section>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                     <dt data-property-name="video">
                       <span class="json-property-name">video:</span>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="file">
+                            <span class="json-property-name">file:</span>
+                            <span class="json-property-type">object</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt class="json-inner-schema">
+                            <section class="json-schema-properties">
+                              <dl>
+                                <dt data-property-name="extensions">
+                                  <span class="json-property-name">extensions:</span>
+                                  <span class="json-property-type">string[]</span>
+                                  <span class="json-property-range" title="Value limits"></span>
+                                </dt>
+                                <dt class="json-inner-schema">
+                                  <section class="json-schema-array-items">
+                                    <span class="json-property-type">string</span>
+                                    <span class="json-property-range" title="Value limits"></span>
+                                    <div class="json-inner-schema"> </div>
+                                  </section>
+                                </dt>
+                              </dl>
+                            </section>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
                       <span class="json-property-type">object</span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-properties">
+                        <dl>
+                          <dt data-property-name="id">
+                            <span class="json-property-name">id:</span>
+                            <span class="json-property-type">number</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                          <dt data-property-name="uuid">
+                            <span class="json-property-name">uuid:</span>
+                            <span class="json-property-type">string</span>
+                            <span class="json-property-range" title="Value limits"></span>
+                          </dt>
+                        </dl>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
                       </span>
                       <span class="json-property-range" title="Value limits"></span>
                     </dt>
+                    <dt class="json-inner-schema">
+                      <section class="json-schema-array-items">
+                        <span class="json-property-type">
+                          <span class="">
+                            <a class="json-schema-ref" href="#/definitions/VideoComment">VideoComment</a>
+                          </span>
+                        </span>
+                        <span class="json-property-range" title="Value limits"></span>
+                        <div class="json-inner-schema"> </div>
+                      </section>
+                    </dt>
                   </dl>
                 </section>
               </div>
index 46b73145a0796cda80bf0502783018f13fa5831c..a1e286973cc8564ac83d236f7bd37e95fecd720b 100644 (file)
@@ -16,7 +16,7 @@ basePath: '/api/v1'
 schemes:
   - https
 paths:
-  '/accounts/{id}':
+  '/accounts/{name}':
     get:
       tags:
         - Accounts
@@ -25,11 +25,11 @@ paths:
       produces:
         - application/json
       parameters:
-        - name: id
+        - name: name
           in: path
           required: true
           type: string
-          description: 'The id of the account'
+          description: 'The name of the account (chocobozzz or chocobozzz@peertube.cpy.re for example)'
         - name: start
           in: query
           required: false
@@ -50,7 +50,7 @@ paths:
           description: successful operation
           schema:
             $ref: '#/definitions/Account'
-  '/accounts/{id}/videos':
+  '/accounts/{name}/videos':
     get:
       tags:
         - Accounts
@@ -59,11 +59,11 @@ paths:
       produces:
         - application/json
       parameters:
-        - name: id
+        - name: name
           in: path
           required: true
           type: string
-          description: 'The id of the account'
+          description: 'The name of the account (chocobozzz or chocobozzz@peertube.cpy.re for example)'
       responses:
         '200':
           description: successful operation
@@ -1112,7 +1112,7 @@ paths:
           description: successful operation
           schema:
             $ref: '#/definitions/Video'
-  /accounts/{accountId}/video-channels:
+  /accounts/{name}/video-channels:
     get:
       tags:
         - VideoChannel
@@ -1121,11 +1121,11 @@ paths:
       produces:
         - application/json
       parameters:
-        - name: accountId
+        - name: name
           in: path
           required: true
           type: string
-          description: 'The account id '
+          description: 'The name of the account (chocobozzz or chocobozzz@peertube.cpy.re for example)'
       responses:
         '200':
           description: successful operation