diff --git a/.changeset/green-timers-cross.md b/.changeset/green-timers-cross.md new file mode 100644 index 00000000000..7af076cc030 --- /dev/null +++ b/.changeset/green-timers-cross.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +notification emails should now show emojis properly diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js index 395ddfe6d46..b3f7a11dc0d 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js +++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js @@ -1,4 +1,5 @@ import { Subscriptions, Users } from '@rocket.chat/models'; +import emojione from 'emojione'; import moment from 'moment'; import { callbacks } from '../../../../lib/callbacks'; @@ -145,12 +146,23 @@ export const sendNotification = async ({ isThread, }) ) { + const messageWithUnicode = message.msg ? emojione.shortnameToUnicode(message.msg) : message.msg; + const firstAttachment = message.attachments?.length > 0 && message.attachments.shift(); + firstAttachment.description = + typeof firstAttachment.description === 'string' ? emojione.shortnameToUnicode(firstAttachment.description) : undefined; + firstAttachment.text = typeof firstAttachment.text === 'string' ? emojione.shortnameToUnicode(firstAttachment.text) : undefined; + + const attachments = firstAttachment ? [firstAttachment, ...message.attachments].filter(Boolean) : []; for await (const email of receiver.emails) { if (email.verified) { queueItems.push({ type: 'email', data: await getEmailData({ - message, + message: { + ...message, + msg: messageWithUnicode, + ...(attachments.length > 0 ? { attachments } : {}), + }, receiver, sender, subscription,