X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fcustom-page.ts;h=d1c672f3fc0a62f6a637caeaafe5dfbc0717dd82;hb=09f3d81e0c8edebbe8f5698811ecfb165f942378;hp=3c47f7b9af6fef11cb26d7f5abbf1518f88f27ef;hpb=1c5e49e75284100b7b1fc8b4e73c8ba53fe22e89;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts index 3c47f7b9a..d1c672f3f 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/controllers/api/custom-page.ts @@ -1,8 +1,7 @@ -import * as express from 'express' +import express from 'express' import { ServerConfigManager } from '@server/lib/server-config-manager' import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { HttpStatusCode } from '@shared/core-utils' -import { UserRight } from '@shared/models' +import { HttpStatusCode, UserRight } from '@shared/models' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' const customPageRouter = express.Router() @@ -27,7 +26,12 @@ export { async function getInstanceHomepage (req: express.Request, res: express.Response) { const page = await ActorCustomPageModel.loadInstanceHomepage() - if (!page) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + if (!page) { + return res.fail({ + status: HttpStatusCode.NOT_FOUND_404, + message: 'Instance homepage could not be found' + }) + } return res.json(page.toFormattedJSON()) } @@ -38,5 +42,5 @@ async function updateInstanceHomepage (req: express.Request, res: express.Respon await ActorCustomPageModel.updateInstanceHomepage(content) ServerConfigManager.Instance.updateHomepageState(content) - return res.sendStatus(HttpStatusCode.NO_CONTENT_204) + return res.status(HttpStatusCode.NO_CONTENT_204).end() }