Skip to content

Commit

Permalink
chore: notify messages on emails incoming and outgoing (#30925)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosSpessatto authored Dec 7, 2023
1 parent cf65ebd commit fa34e42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { api } from '@rocket.chat/core-services';
import type {
ILivechatVisitor,
IOmnichannelRoom,
Expand All @@ -16,6 +17,7 @@ import { Livechat as LivechatTyped } from '../../../app/livechat/server/lib/Live
import { QueueManager } from '../../../app/livechat/server/lib/QueueManager';
import { settings } from '../../../app/settings/server';
import { i18n } from '../../lib/i18n';
import { broadcastMessageSentEvent } from '../../modules/watchers/lib/messages';
import { logger } from './logger';

type FileAttachment = VideoAttachmentProps & ImageAttachmentProps & AudioAttachmentProps;
Expand Down Expand Up @@ -236,6 +238,10 @@ export async function onEmailReceived(email: ParsedMail, inbox: string, departme
},
);
room && (await LivechatRooms.updateEmailThreadByRoomId(room._id, thread));
void broadcastMessageSentEvent({
id: msgId,
broadcastCallback: (message) => api.broadcast('message.sent', message),
});
})
.catch((err) => {
logger.error({
Expand Down
6 changes: 6 additions & 0 deletions apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { api } from '@rocket.chat/core-services';
import { isIMessageInbox } 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';
Expand All @@ -10,6 +11,7 @@ import { settings } from '../../../app/settings/server';
import { slashCommands } from '../../../app/utils/server/slashCommand';
import { callbacks } from '../../../lib/callbacks';
import { i18n } from '../../lib/i18n';
import { broadcastMessageSentEvent } from '../../modules/watchers/lib/messages';
import { inboxes } from './EmailInbox';
import type { Inbox } from './EmailInbox';
import { logger } from './logger';
Expand Down Expand Up @@ -170,6 +172,10 @@ slashCommands.add({
},
},
);
void broadcastMessageSentEvent({
id: message._id,
broadcastCallback: (message) => api.broadcast('message.sent', message),
});

return sendSuccessReplyMessage({
msgId: message._id,
Expand Down

0 comments on commit fa34e42

Please sign in to comment.