Skip to content

Commit

Permalink
feat: Convert emoji shortname to unicode on notification emails. (#31225
Browse files Browse the repository at this point in the history
)
  • Loading branch information
gabriellsh authored Jan 22, 2024
1 parent 3fdf8ac commit 9217c4f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-timers-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

notification emails should now show emojis properly
14 changes: 13 additions & 1 deletion apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Subscriptions, Users } from '@rocket.chat/models';
import emojione from 'emojione';
import moment from 'moment';

import { callbacks } from '../../../../lib/callbacks';
Expand Down Expand Up @@ -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();

This comment has been minimized.

Copy link
@ggazzo

ggazzo Jan 23, 2024

Member

what happens if the length is === 0 ?

firstAttachment.description = ... this is going to fail

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,
Expand Down

0 comments on commit 9217c4f

Please sign in to comment.