Merge branch 'main' into 993-bug-console-chat-widget-doesnt-show-quick-replies

This commit is contained in:
yassinedorbozgithub 2025-05-13 08:11:48 +01:00
commit 11bda74568
6 changed files with 23 additions and 54 deletions

View File

@ -309,8 +309,9 @@ export default abstract class ChannelHandler<
*/
public async getPublicUrl(attachment: AttachmentRef | Attachment) {
const [name, _suffix] = this.getName().split('-');
if ('id' in attachment) {
if (attachment && 'id' in attachment) {
if (!attachment || !attachment.id) {
this.logger.warn('Unable to build public URL: Empty attachment ID');
return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);
}
@ -330,6 +331,10 @@ export default abstract class ChannelHandler<
// In case the url is external
return attachment.url;
} else {
this.logger.warn(
'Unable to resolve the attachment public URL.',
attachment,
);
return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);
}
}

View File

@ -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:
* 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')
@Get(':channel/not-found')
async handleNotFound(@Res() res: Response) {
return res.status(404).send({ error: 'Not found!' });
return res.status(404).send({ error: 'Resource not found!' });
}
}

View File

@ -11,9 +11,6 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule } from '@nestjs/mongoose';
import { AttachmentModule } from '@/attachment/attachment.module';
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service';
import { ChannelModule } from '@/channel/channel.module';
import { CmsModule } from '@/cms/cms.module';
import { UserModule } from '@/user/user.module';
@ -61,7 +58,6 @@ import { SubscriberService } from './services/subscriber.service';
SubscriberModel,
ConversationModel,
SubscriberModel,
AttachmentModel,
]),
forwardRef(() => ChannelModule),
CmsModule,
@ -96,8 +92,6 @@ import { SubscriberService } from './services/subscriber.service';
ConversationService,
ChatService,
BotService,
AttachmentService,
AttachmentRepository,
],
exports: [
SubscriberService,

View File

@ -11,14 +11,8 @@ import {
InternalServerErrorException,
Optional,
} from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { Document, Query } from 'mongoose';
import { Attachment } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service';
import { DeleteResult } from '@/utils/generics/base-repository';
import { BaseService } from '@/utils/generics/base-service';
import { TFilterQuery } from '@/utils/types/filter.types';
import {
SocketGet,
SocketPost,
@ -46,7 +40,6 @@ export class MessageService extends BaseService<
constructor(
private readonly messageRepository: MessageRepository,
private attachmentService: AttachmentService,
@Optional() gateway?: WebsocketGateway,
) {
super(messageRepository);
@ -140,40 +133,4 @@ export class MessageService extends BaseService<
return lastMessages.reverse();
}
@OnEvent('hook:attachment:preDelete')
async handleDeleteImage(
_query: Query<
DeleteResult,
Document<Attachment, any, any>,
unknown,
Attachment,
'deleteOne' | 'deleteMany'
>,
criteria: TFilterQuery<Attachment>,
) {
try {
this.logger.log(
'deleting attachment messages containing deleted images',
criteria,
);
const foundAttachments = await this.attachmentService.find(criteria);
for (const attachment of foundAttachments) {
await this.updateMany(
{
'message.attachment.payload.id': attachment.id,
},
{
['message.attachment.payload.id' as any]: null,
},
);
}
} catch (error) {
this.logger.error(
'Unable to cleanup old messages with attachment ids',
error,
);
}
}
}

View File

@ -57,10 +57,19 @@ export const SubscribersList = (props: {
</Grid>
{subscribers?.length > 0 ? (
<ConversationList
scrollable
scrollable={false}
loading={isFetching}
loadingMore={isFetching}
onYReachEnd={handleLoadMore}
onScroll={({ target }) => {
const container = target as HTMLDivElement;
if (
container.scrollTop + container.clientHeight >=
container.scrollHeight
) {
handleLoadMore();
}
}}
>
{subscribers.map((subscriber) => (
<Conversation

View File

@ -55,6 +55,10 @@ div .cs-message-input__content-editor-container,
background-color: var(--cs-message-input-bg) !important;
}
.cs-conversation-list {
overflow: auto !important;
}
.cs-conversation__info {
color: #0e2525 !important;
font-weight: 200;