mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch 'main' into 993-bug-console-chat-widget-doesnt-show-quick-replies
This commit is contained in:
commit
11bda74568
@ -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!' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,6 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
|
|||||||
import { MongooseModule } from '@nestjs/mongoose';
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
|
||||||
import { AttachmentModule } from '@/attachment/attachment.module';
|
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 { ChannelModule } from '@/channel/channel.module';
|
||||||
import { CmsModule } from '@/cms/cms.module';
|
import { CmsModule } from '@/cms/cms.module';
|
||||||
import { UserModule } from '@/user/user.module';
|
import { UserModule } from '@/user/user.module';
|
||||||
@ -61,7 +58,6 @@ import { SubscriberService } from './services/subscriber.service';
|
|||||||
SubscriberModel,
|
SubscriberModel,
|
||||||
ConversationModel,
|
ConversationModel,
|
||||||
SubscriberModel,
|
SubscriberModel,
|
||||||
AttachmentModel,
|
|
||||||
]),
|
]),
|
||||||
forwardRef(() => ChannelModule),
|
forwardRef(() => ChannelModule),
|
||||||
CmsModule,
|
CmsModule,
|
||||||
@ -96,8 +92,6 @@ import { SubscriberService } from './services/subscriber.service';
|
|||||||
ConversationService,
|
ConversationService,
|
||||||
ChatService,
|
ChatService,
|
||||||
BotService,
|
BotService,
|
||||||
AttachmentService,
|
|
||||||
AttachmentRepository,
|
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
SubscriberService,
|
SubscriberService,
|
||||||
|
@ -11,14 +11,8 @@ import {
|
|||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
Optional,
|
Optional,
|
||||||
} from '@nestjs/common';
|
} 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 { BaseService } from '@/utils/generics/base-service';
|
||||||
import { TFilterQuery } from '@/utils/types/filter.types';
|
|
||||||
import {
|
import {
|
||||||
SocketGet,
|
SocketGet,
|
||||||
SocketPost,
|
SocketPost,
|
||||||
@ -46,7 +40,6 @@ export class MessageService extends BaseService<
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly messageRepository: MessageRepository,
|
private readonly messageRepository: MessageRepository,
|
||||||
private attachmentService: AttachmentService,
|
|
||||||
@Optional() gateway?: WebsocketGateway,
|
@Optional() gateway?: WebsocketGateway,
|
||||||
) {
|
) {
|
||||||
super(messageRepository);
|
super(messageRepository);
|
||||||
@ -140,40 +133,4 @@ export class MessageService extends BaseService<
|
|||||||
|
|
||||||
return lastMessages.reverse();
|
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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,19 @@ export const SubscribersList = (props: {
|
|||||||
</Grid>
|
</Grid>
|
||||||
{subscribers?.length > 0 ? (
|
{subscribers?.length > 0 ? (
|
||||||
<ConversationList
|
<ConversationList
|
||||||
scrollable
|
scrollable={false}
|
||||||
loading={isFetching}
|
loading={isFetching}
|
||||||
loadingMore={isFetching}
|
loadingMore={isFetching}
|
||||||
onYReachEnd={handleLoadMore}
|
onScroll={({ target }) => {
|
||||||
|
const container = target as HTMLDivElement;
|
||||||
|
|
||||||
|
if (
|
||||||
|
container.scrollTop + container.clientHeight >=
|
||||||
|
container.scrollHeight
|
||||||
|
) {
|
||||||
|
handleLoadMore();
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{subscribers.map((subscriber) => (
|
{subscribers.map((subscriber) => (
|
||||||
<Conversation
|
<Conversation
|
||||||
|
@ -55,6 +55,10 @@ div .cs-message-input__content-editor-container,
|
|||||||
background-color: var(--cs-message-input-bg) !important;
|
background-color: var(--cs-message-input-bg) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cs-conversation-list {
|
||||||
|
overflow: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
.cs-conversation__info {
|
.cs-conversation__info {
|
||||||
color: #0e2525 !important;
|
color: #0e2525 !important;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
|
Loading…
Reference in New Issue
Block a user