mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge pull request #997 from Hexastack/fix/channel-not-found-add-message-logs
fix: add warn message to not found resource
This commit is contained in:
commit
55f18fc767
@ -309,8 +309,9 @@ export default abstract class ChannelHandler<
|
|||||||
*/
|
*/
|
||||||
public async getPublicUrl(attachment: AttachmentRef | Attachment) {
|
public async getPublicUrl(attachment: AttachmentRef | Attachment) {
|
||||||
const [name, _suffix] = this.getName().split('-');
|
const [name, _suffix] = this.getName().split('-');
|
||||||
if ('id' in attachment) {
|
if (attachment && 'id' in attachment) {
|
||||||
if (!attachment || !attachment.id) {
|
if (!attachment || !attachment.id) {
|
||||||
|
this.logger.warn('Unable to build public URL: Empty attachment ID');
|
||||||
return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);
|
return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,6 +331,10 @@ export default abstract class ChannelHandler<
|
|||||||
// In case the url is external
|
// In case the url is external
|
||||||
return attachment.url;
|
return attachment.url;
|
||||||
} else {
|
} else {
|
||||||
|
this.logger.warn(
|
||||||
|
'Unable to resolve the attachment public URL.',
|
||||||
|
attachment,
|
||||||
|
);
|
||||||
return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);
|
return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -92,6 +92,6 @@ export class WebhookController {
|
|||||||
@Roles('public')
|
@Roles('public')
|
||||||
@Get(':channel/not-found')
|
@Get(':channel/not-found')
|
||||||
async handleNotFound(@Res() res: Response) {
|
async handleNotFound(@Res() res: Response) {
|
||||||
return res.status(404).send({ error: 'Not found!' });
|
return res.status(404).send({ error: 'Resource not found!' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user