From 9a911038d9ac38bf590e9199b3b7477ebf91de19 Mon Sep 17 00:00:00 2001 From: Kimsible Date: Sat, 24 Apr 2021 01:44:39 +0200 Subject: Add shorter URLs for accounts and channels server-side --- server/lib/client-html.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'server/lib') diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 203bd3893..cac9edb30 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -196,11 +196,24 @@ class ClientHtml { } static async getAccountHTMLPage (nameWithHost: string, req: express.Request, res: express.Response) { - return this.getAccountOrChannelHTMLPage(() => AccountModel.loadByNameWithHost(nameWithHost), req, res) + const accountModelPromise = AccountModel.loadByNameWithHost(nameWithHost) + return this.getAccountOrChannelHTMLPage(() => accountModelPromise, req, res) } static async getVideoChannelHTMLPage (nameWithHost: string, req: express.Request, res: express.Response) { - return this.getAccountOrChannelHTMLPage(() => VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost), req, res) + const videoChannelModelPromise = VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost) + return this.getAccountOrChannelHTMLPage(() => videoChannelModelPromise, req, res) + } + + static async getActorHTMLPage (nameWithHost: string, req: express.Request, res: express.Response) { + const accountModel = await AccountModel.loadByNameWithHost(nameWithHost) + + if (accountModel) { + return this.getAccountOrChannelHTMLPage(() => new Promise(resolve => resolve(accountModel)), req, res) + } else { + const videoChannelModelPromise = VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost) + return this.getAccountOrChannelHTMLPage(() => videoChannelModelPromise, req, res) + } } static async getEmbedHTML () { -- cgit v1.2.3