feat: Convert emoji shortname to unicode on notification emails. (#31225)

pull/31426/head^2
gabriellsh 2 years ago committed by GitHub
parent 3fdf8ac956
commit 9217c4fcf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/green-timers-cross.md
  2. 14
      apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js

@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---
notification emails should now show emojis properly

@ -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,

Loading…
Cancel
Save