mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
check if previews are disabled before anything else
This commit is contained in:
parent
b1876bf06e
commit
f4107b1c2b
1 changed files with 10 additions and 10 deletions
|
@ -123,6 +123,16 @@ export class UrlPreviewService {
|
|||
request: FastifyRequest<PreviewRoute>,
|
||||
reply: FastifyReply,
|
||||
): Promise<void> {
|
||||
if (!this.meta.urlPreviewEnabled) {
|
||||
return reply.code(403).send({
|
||||
error: {
|
||||
message: 'URL preview is disabled',
|
||||
code: 'URL_PREVIEW_DISABLED',
|
||||
id: '58b36e13-d2f5-0323-b0c6-76aa9dabefb8',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const url = request.query.url;
|
||||
if (typeof url !== 'string' || !URL.canParse(url)) {
|
||||
reply.code(400);
|
||||
|
@ -135,16 +145,6 @@ export class UrlPreviewService {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.meta.urlPreviewEnabled) {
|
||||
return reply.code(403).send({
|
||||
error: {
|
||||
message: 'URL preview is disabled',
|
||||
code: 'URL_PREVIEW_DISABLED',
|
||||
id: '58b36e13-d2f5-0323-b0c6-76aa9dabefb8',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Check rate limit
|
||||
const auth = await this.authenticate(request);
|
||||
if (!await this.checkRateLimit(auth, reply)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue