Skip to content
Snippets Groups Projects
Unverified Commit fa34e422 authored by Marcos Spessatto Defendi's avatar Marcos Spessatto Defendi Committed by GitHub
Browse files

chore: notify messages on emails incoming and outgoing (#30925)

parent cf65ebde
No related branches found
No related tags found
No related merge requests found
import { api } from '@rocket.chat/core-services';
import type { import type {
ILivechatVisitor, ILivechatVisitor,
IOmnichannelRoom, IOmnichannelRoom,
...@@ -16,6 +17,7 @@ import { Livechat as LivechatTyped } from '../../../app/livechat/server/lib/Live ...@@ -16,6 +17,7 @@ import { Livechat as LivechatTyped } from '../../../app/livechat/server/lib/Live
import { QueueManager } from '../../../app/livechat/server/lib/QueueManager'; import { QueueManager } from '../../../app/livechat/server/lib/QueueManager';
import { settings } from '../../../app/settings/server'; import { settings } from '../../../app/settings/server';
import { i18n } from '../../lib/i18n'; import { i18n } from '../../lib/i18n';
import { broadcastMessageSentEvent } from '../../modules/watchers/lib/messages';
import { logger } from './logger'; import { logger } from './logger';
type FileAttachment = VideoAttachmentProps & ImageAttachmentProps & AudioAttachmentProps; type FileAttachment = VideoAttachmentProps & ImageAttachmentProps & AudioAttachmentProps;
...@@ -236,6 +238,10 @@ export async function onEmailReceived(email: ParsedMail, inbox: string, departme ...@@ -236,6 +238,10 @@ export async function onEmailReceived(email: ParsedMail, inbox: string, departme
}, },
); );
room && (await LivechatRooms.updateEmailThreadByRoomId(room._id, thread)); room && (await LivechatRooms.updateEmailThreadByRoomId(room._id, thread));
void broadcastMessageSentEvent({
id: msgId,
broadcastCallback: (message) => api.broadcast('message.sent', message),
});
}) })
.catch((err) => { .catch((err) => {
logger.error({ logger.error({
......
import { api } from '@rocket.chat/core-services';
import { isIMessageInbox } from '@rocket.chat/core-typings'; import { isIMessageInbox } from '@rocket.chat/core-typings';
import type { IEmailInbox, IUser, IMessage, IOmnichannelRoom, SlashCommandCallbackParams } from '@rocket.chat/core-typings'; import type { IEmailInbox, IUser, IMessage, IOmnichannelRoom, SlashCommandCallbackParams } from '@rocket.chat/core-typings';
import { Messages, Uploads, LivechatRooms, Rooms, Users } from '@rocket.chat/models'; import { Messages, Uploads, LivechatRooms, Rooms, Users } from '@rocket.chat/models';
...@@ -10,6 +11,7 @@ import { settings } from '../../../app/settings/server'; ...@@ -10,6 +11,7 @@ import { settings } from '../../../app/settings/server';
import { slashCommands } from '../../../app/utils/server/slashCommand'; import { slashCommands } from '../../../app/utils/server/slashCommand';
import { callbacks } from '../../../lib/callbacks'; import { callbacks } from '../../../lib/callbacks';
import { i18n } from '../../lib/i18n'; import { i18n } from '../../lib/i18n';
import { broadcastMessageSentEvent } from '../../modules/watchers/lib/messages';
import { inboxes } from './EmailInbox'; import { inboxes } from './EmailInbox';
import type { Inbox } from './EmailInbox'; import type { Inbox } from './EmailInbox';
import { logger } from './logger'; import { logger } from './logger';
...@@ -170,6 +172,10 @@ slashCommands.add({ ...@@ -170,6 +172,10 @@ slashCommands.add({
}, },
}, },
); );
void broadcastMessageSentEvent({
id: message._id,
broadcastCallback: (message) => api.broadcast('message.sent', message),
});
return sendSuccessReplyMessage({ return sendSuccessReplyMessage({
msgId: message._id, msgId: message._id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment