From 60fa9482c50ed8f1d944be4161c11c505d35918a Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Fri, 9 May 2025 08:26:36 +0100 Subject: [PATCH 1/7] fix(frontend): resolve inbox scrolling top issue --- .../inbox/components/ConversationsList.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/inbox/components/ConversationsList.tsx b/frontend/src/components/inbox/components/ConversationsList.tsx index fc0f388e..a47f8b11 100644 --- a/frontend/src/components/inbox/components/ConversationsList.tsx +++ b/frontend/src/components/inbox/components/ConversationsList.tsx @@ -57,10 +57,19 @@ export const SubscribersList = (props: { {subscribers?.length > 0 ? ( { + const container = target as HTMLDivElement; + + if ( + container.scrollTop + container.clientHeight >= + container.scrollHeight + ) { + handleLoadMore(); + } + }} > {subscribers.map((subscriber) => ( Date: Fri, 9 May 2025 08:33:54 +0100 Subject: [PATCH 2/7] fix(frontend): update style to css class --- .../src/components/inbox/components/ConversationsList.tsx | 3 ++- frontend/src/components/inbox/inbox.css | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/inbox/components/ConversationsList.tsx b/frontend/src/components/inbox/components/ConversationsList.tsx index a47f8b11..a612f42f 100644 --- a/frontend/src/components/inbox/components/ConversationsList.tsx +++ b/frontend/src/components/inbox/components/ConversationsList.tsx @@ -57,7 +57,8 @@ export const SubscribersList = (props: { {subscribers?.length > 0 ? ( { diff --git a/frontend/src/components/inbox/inbox.css b/frontend/src/components/inbox/inbox.css index 55bf77f4..330e6c2b 100644 --- a/frontend/src/components/inbox/inbox.css +++ b/frontend/src/components/inbox/inbox.css @@ -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; From 122395006b9110c3588823d9e60f4279fcf78ac0 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Fri, 9 May 2025 08:36:10 +0100 Subject: [PATCH 3/7] fix(frontend): remove classname automatically aded by chat-ui-kit --- frontend/src/components/inbox/components/ConversationsList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/inbox/components/ConversationsList.tsx b/frontend/src/components/inbox/components/ConversationsList.tsx index a612f42f..3a1b1c8b 100644 --- a/frontend/src/components/inbox/components/ConversationsList.tsx +++ b/frontend/src/components/inbox/components/ConversationsList.tsx @@ -57,7 +57,6 @@ export const SubscribersList = (props: { {subscribers?.length > 0 ? ( Date: Fri, 9 May 2025 15:58:16 +0100 Subject: [PATCH 4/7] fix: add warn message to not found resource --- api/src/channel/lib/Handler.ts | 5 +++++ api/src/channel/webhook.controller.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/channel/lib/Handler.ts b/api/src/channel/lib/Handler.ts index c454b365..7e87676d 100644 --- a/api/src/channel/lib/Handler.ts +++ b/api/src/channel/lib/Handler.ts @@ -311,6 +311,7 @@ export default abstract class ChannelHandler< const [name, _suffix] = this.getName().split('-'); if ('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`); } } diff --git a/api/src/channel/webhook.controller.ts b/api/src/channel/webhook.controller.ts index e8e4f0eb..63a14962 100644 --- a/api/src/channel/webhook.controller.ts +++ b/api/src/channel/webhook.controller.ts @@ -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!' }); } } From 4f012594cbf982805b06795dccc9071d347fff60 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Fri, 9 May 2025 16:42:00 +0100 Subject: [PATCH 5/7] feat: undo message attachment reference removal --- api/src/chat/services/message.service.ts | 43 ------------------------ 1 file changed, 43 deletions(-) diff --git a/api/src/chat/services/message.service.ts b/api/src/chat/services/message.service.ts index d6b210ea..604cb51a 100644 --- a/api/src/chat/services/message.service.ts +++ b/api/src/chat/services/message.service.ts @@ -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, @@ -45,7 +39,6 @@ export class MessageService extends BaseService< constructor( private readonly messageRepository: MessageRepository, - private attachmentService: AttachmentService, @Optional() gateway?: WebsocketGateway, ) { super(messageRepository); @@ -134,40 +127,4 @@ export class MessageService extends BaseService< return lastMessages.reverse(); } - - @OnEvent('hook:attachment:preDelete') - async handleDeleteImage( - _query: Query< - DeleteResult, - Document, - unknown, - Attachment, - 'deleteOne' | 'deleteMany' - >, - criteria: TFilterQuery, - ) { - 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, - ); - } - } } From 0112ceebe2176849961d0d57deabe526b6ea963a Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Fri, 9 May 2025 16:46:07 +0100 Subject: [PATCH 6/7] fix: remove unecessary providers import --- api/src/chat/chat.module.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/api/src/chat/chat.module.ts b/api/src/chat/chat.module.ts index 1452d296..09b21f7b 100644 --- a/api/src/chat/chat.module.ts +++ b/api/src/chat/chat.module.ts @@ -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, From 72c9484ff6c451cca24ac88c1ef55d3c95354e5c Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Mon, 12 May 2025 14:33:08 +0100 Subject: [PATCH 7/7] fix: extra check --- api/src/channel/lib/Handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/channel/lib/Handler.ts b/api/src/channel/lib/Handler.ts index 7e87676d..3d76f47e 100644 --- a/api/src/channel/lib/Handler.ts +++ b/api/src/channel/lib/Handler.ts @@ -309,7 +309,7 @@ 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`);