Skip to content

Commit 9d1d0bb

Browse files
committed
fix: add backend validation for livechat offline message recipient
1 parent 71ba727 commit 9d1d0bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apps/meteor/app/livechat/server/lib/messages.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export async function sendOfflineMessage(data: OfflineMessageData) {
6565
}
6666
}
6767

68-
// TODO Block offline form if Livechat_offline_email is undefined
69-
// (it does not make sense to have an offline form that does nothing)
70-
// `this.sendEmail` will throw an error if the email is invalid
71-
// thus this breaks livechat, since the "to" email is invalid, and that returns an [invalid email] error to the livechat client
7268
let emailTo = settings.get<string>('Livechat_offline_email');
7369
if (department && department !== '') {
7470
const dep = await LivechatDepartment.findOneByIdOrName(department, { projection: { email: 1 } });
@@ -77,6 +73,10 @@ export async function sendOfflineMessage(data: OfflineMessageData) {
7773
}
7874
}
7975

76+
if (!emailTo) {
77+
throw new Error('error-no-email-configured-to-receive-offline-messages');
78+
}
79+
8080
const fromText = `${name} - ${email} <${from}>`;
8181
const replyTo = `${name} <${email}>`;
8282
const subject = `Livechat offline message from ${name}: ${`${emailMessage}`.substring(0, 20)}`;

0 commit comments

Comments
 (0)