ActivityPub-federated video streaming platform using P2P directly in your web browser
Only use account name in routes
Chocobozzzad9e39fb815d
diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.tsindex 0852c4bb75..a6e6dd656b 100644--- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts+++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts@@ -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)diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.tsindex 7abf48826b..20c8798d15 100644--- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts+++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts@@ -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)}}diff --git a/client/src/app/+video-channels/video-channels.component.html b/client/src/app/+video-channels/video-channels.component.htmlindex da0d76acfe..6b25d16ab7 100644--- a/client/src/app/+video-channels/video-channels.component.html+++ b/client/src/app/+video-channels/video-channels.component.html@@ -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>diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.htmlindex 6a2a495a28..1a95477b76 100644--- a/client/src/app/menu/menu.component.html+++ b/client/src/app/menu/menu.component.html@@ -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>diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.tsindex 6a3c6451c4..5058e372fd 100644--- a/client/src/app/shared/account/account.model.ts+++ b/client/src/app/shared/account/account.model.ts@@ -4,11 +4,13 @@ import { Actor } from '../actor/actor.model'export class Account extends Actor implements ServerAccount {displayName: stringdescription: string+ nameWithHost: stringconstructor (hash: ServerAccount) {super(hash)this.displayName = hash.displayNamethis.description = hash.description+ this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)}}diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.tsindex d4551de894..b4be2270f8 100644--- a/client/src/app/shared/users/user.model.ts+++ b/client/src/app/shared/users/user.model.ts@@ -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.usernamethis.email = hash.emailthis.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()}diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.tsindex e1e3bf6979..55e4c2a312 100644--- a/client/src/app/shared/video-channel/video-channel.service.ts+++ b/client/src/app/shared/video-channel/video-channel.service.ts@@ -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))diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.tsindex 5397aa37f7..5fc55fca60 100644--- a/client/src/app/shared/video/video-details.model.ts+++ b/client/src/app/shared/video/video-details.model.ts@@ -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.descriptionPaththis.files = hash.filesthis.channel = hash.channel- this.account = hash.account+ this.account = new Account(hash.account)this.tags = hash.tagsthis.support = hash.supportthis.commentsEnabled = hash.commentsEnableddiff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.htmlindex 1725e9f5cb..09ce0ef7f1 100644--- a/client/src/app/shared/video/video-miniature.component.html+++ b/client/src/app/shared/video/video-miniature.component.html@@ -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>diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.tsindex 5b8e2467a6..d1e32faebd 100644--- a/client/src/app/shared/video/video.service.ts+++ b/client/src/app/shared/video/video.service.ts@@ -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))diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.tsindex 00c2ed3f11..339da1bf47 100644--- a/client/src/app/videos/+video-edit/video-update.component.ts+++ b/client/src/app/videos/+video-edit/video-update.component.ts@@ -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 }))),diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.htmlindex 212bfdd8cc..583a975626 100644--- a/client/src/app/videos/+video-watch/video-watch.component.html+++ b/client/src/app/videos/+video-watch/video-watch.component.html@@ -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>diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.tsindex ccae0436b1..8e937276cd 100644--- a/server/controllers/api/accounts.ts+++ b/server/controllers/api/accounts.ts@@ -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))diff --git a/server/controllers/services.ts b/server/controllers/services.tsindex c272edccd5..a58a5b8cf2 100644--- a/server/controllers/services.ts+++ b/server/controllers/services.ts@@ -10,7 +10,7 @@ servicesRouter.use('/oembed',asyncMiddleware(oembedValidator),generateOEmbed)-servicesRouter.use('/redirect/accounts/:nameWithHost',+servicesRouter.use('/redirect/accounts/:accountName',asyncMiddleware(accountsNameWithHostGetValidator),redirectToAccountUrl)diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.tsindex 00dea9039d..0607d661c2 100644--- a/server/helpers/custom-validators/accounts.ts+++ b/server/helpers/custom-validators/accounts.ts@@ -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, sendconst [ 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)diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.tsindex c01e742da3..b3a51e631a 100644--- a/server/middlewares/validators/account.ts+++ b/server/middlewares/validators/account.ts@@ -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)) returnreturn next()}@@ -59,6 +34,5 @@ const accountsNameWithHostGetValidator = [export {localAccountValidator,- accountsGetValidator,accountsNameWithHostGetValidator}diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.tsindex 92c0de419e..a5be5f1146 100644--- a/server/middlewares/validators/video-channels.ts+++ b/server/middlewares/validators/video-channels.ts@@ -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)) returnreturn next()}diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.tsindex 50dc0804ef..9e0b1e35c6 100644--- a/server/tests/api/check-params/accounts.ts+++ b/server/tests/api/check-params/accounts.ts@@ -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)})})diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.tsindex 56b990be6f..5080af2c96 100644--- a/server/tests/api/check-params/video-channels.ts+++ b/server/tests/api/check-params/video-channels.ts@@ -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)})})diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.tsindex c81e9752ef..7b40b91e70 100644--- a/server/tests/api/check-params/videos.ts+++ b/server/tests/api/check-params/videos.ts@@ -18,7 +18,7 @@ describe('Test videos API validator', function () {const path = '/api/v1/videos/'let server: ServerInfolet userAccessToken = ''- let accountUUID: string+ let accountName: stringlet channelId: numberlet channelUUID: stringlet videoId@@ -43,7 +43,7 @@ describe('Test videos API validator', function () {const res = await getMyUserInformation(server.url, server.accessToken)channelId = res.body.videoChannels[ 0 ].idchannelUUID = 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: stringbefore(async function () {- path = '/api/v1/accounts/' + accountUUID + '/videos'+ path = '/api/v1/accounts/' + accountName + '/videos'})it('Should fail with a bad start pagination', async function () {diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.tsindex 8b9b63348c..0e1e6c97db 100644--- a/server/tests/api/users/users-multiple-servers.ts+++ b/server/tests/api/users/users-multiple-servers.ts@@ -26,7 +26,7 @@ const expect = chai.expectdescribe('Test users with multiple servers', function () {let servers: ServerInfo[] = []let user: User- let userAccountUUID: string+ let userAccountName: stringlet userVideoChannelUUID: stringlet userId: numberlet 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.uuiduserId = 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 Accountexpect(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 Accountexpect(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)}})diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.tsindex 35c418f7c6..7ae505fd78 100644--- a/server/tests/api/videos/video-channels.ts+++ b/server/tests/api/videos/video-channels.ts@@ -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)diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.tsindex b8c85f45b3..a8f1525610 100644--- a/server/tests/api/videos/video-nsfw.ts+++ b/server/tests/api/videos/video-nsfw.ts@@ -32,13 +32,13 @@ describe('Test video NSFW policy', function () {.then(res => {const user: User = res.bodyconst videoChannelUUID = user.videoChannels[0].uuid- const accountUUID = user.account.uuid+ const accountName = user.account.name + '@' + user.account.hostif (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)])})diff --git a/server/tests/utils/users/accounts.ts b/server/tests/utils/users/accounts.tsindex a5c13c319a..30b3c54f8e 100644--- a/server/tests/utils/users/accounts.ts+++ b/server/tests/utils/users/accounts.ts@@ -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/' + accountNamereturn makeGetRequest({url,diff --git a/server/tests/utils/videos/video-channels.ts b/server/tests/utils/videos/video-channels.tsindex 021c4c420c..a064598f47 100644--- a/server/tests/utils/videos/video-channels.ts+++ b/server/tests/utils/videos/video-channels.ts@@ -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)diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.tsindex 07c4ffc776..46fa5f79d3 100644--- a/server/tests/utils/videos/videos.ts+++ b/server/tests/utils/videos/videos.ts@@ -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,diff --git a/support/doc/api/html/index.html b/support/doc/api/html/index.htmlindex d41fc39132..b75a2a8ba5 100644--- a/support/doc/api/html/index.html+++ b/support/doc/api/html/index.html@@ -25,10 +25,10 @@<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>@@ -205,7 +205,7 @@<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>@@ -333,7 +333,7 @@</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">@@ -345,7 +345,7 @@<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">@@ -353,7 +353,7 @@<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">@@ -362,7 +362,8 @@</div></div><div class="prop-value">- <p>The id of the account</p>+ <p>The name of the account (chocobozzz or+ <a href="mailto:[email protected]">[email protected]</a> for example)</p></div></div><div class="prop-row prop-group">@@ -458,7 +459,7 @@</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">@@ -470,7 +471,7 @@<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">@@ -478,7 +479,7 @@<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">@@ -487,7 +488,8 @@</div></div><div class="prop-value">- <p>The id of the account</p>+ <p>The name of the account (chocobozzz or+ <a href="mailto:[email protected]">[email protected]</a> for example)</p></div></div></section>@@ -5329,7 +5331,7 @@</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">@@ -5341,7 +5343,7 @@<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">@@ -5349,7 +5351,7 @@<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">@@ -5358,7 +5360,8 @@</div></div><div class="prop-value">- <p>The account id </p>+ <p>The name of the account (chocobozzz or+ <a href="mailto:[email protected]">[email protected]</a> for example)</p></div></div></section>@@ -6403,6 +6406,41 @@<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>@@ -6494,6 +6532,32 @@<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>@@ -6671,6 +6735,22 @@<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>@@ -6830,6 +6910,17 @@</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>@@ -7210,6 +7301,17 @@</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>@@ -7278,21 +7380,124 @@<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>@@ -7579,6 +7784,22 @@<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>@@ -7624,6 +7845,17 @@</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>diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yamlindex 46b73145a0..a1e286973c 100644--- a/support/doc/api/openapi.yaml+++ b/support/doc/api/openapi.yaml@@ -16,7 +16,7 @@ basePath: '/api/v1'schemes:- httpspaths:- '/accounts/{id}':+ '/accounts/{name}':get:tags:- Accounts@@ -25,11 +25,11 @@ paths:produces:- application/jsonparameters:- - name: id+ - name: namein: pathrequired: truetype: string- description: 'The id of the account'+ description: 'The name of the account (chocobozzz or [email protected] for example)'- name: startin: queryrequired: false@@ -50,7 +50,7 @@ paths:description: successful operationschema:$ref: '#/definitions/Account'- '/accounts/{id}/videos':+ '/accounts/{name}/videos':get:tags:- Accounts@@ -59,11 +59,11 @@ paths:produces:- application/jsonparameters:- - name: id+ - name: namein: pathrequired: truetype: string- description: 'The id of the account'+ description: 'The name of the account (chocobozzz or [email protected] for example)'responses:'200':description: successful operation@@ -1112,7 +1112,7 @@ paths:description: successful operationschema:$ref: '#/definitions/Video'- /accounts/{accountId}/video-channels:+ /accounts/{name}/video-channels:get:tags:- VideoChannel@@ -1121,11 +1121,11 @@ paths:produces:- application/jsonparameters:- - name: accountId+ - name: namein: pathrequired: truetype: string- description: 'The account id '+ description: 'The name of the account (chocobozzz or [email protected] for example)'responses:'200':description: successful operation