From 807118323fd38cb47ba1824323d0e28eb83765d3 Mon Sep 17 00:00:00 2001 From: gabriellsh Date: Tue, 23 Jan 2024 16:17:04 -0300 Subject: [PATCH] do not assign to undefined --- .../app/lib/server/lib/sendNotificationsOnMessage.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js index b3f7a11dc0d7..03a155fa8c17 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js +++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js @@ -148,9 +148,11 @@ export const sendNotification = async ({ ) { 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; + if (firstAttachment) { + 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) {