From 7cd00ea563ca14283ce1fadd92a1244a3015fffa Mon Sep 17 00:00:00 2001 From: Shrinish Vhanbatte <56491104+shrinish123@users.noreply.github.com> Date: Mon, 7 Nov 2022 03:52:39 +0530 Subject: [PATCH] [FIX] Adding error message for wrong dates (#21677) Co-authored-by: Kevin Aleman Co-authored-by: Guilherme Gazzo --- apps/meteor/app/api/server/v1/rooms.js | 4 ++++ apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json | 1 + 2 files changed, 5 insertions(+) diff --git a/apps/meteor/app/api/server/v1/rooms.js b/apps/meteor/app/api/server/v1/rooms.js index ee059908eda04..aab20cbc0238b 100644 --- a/apps/meteor/app/api/server/v1/rooms.js +++ b/apps/meteor/app/api/server/v1/rooms.js @@ -540,6 +540,10 @@ API.v1.addRoute( dateTo = new Date(dateTo); dateTo.setDate(dateTo.getDate() + 1); + if (dateFrom > dateTo) { + throw new Meteor.Error('error-invalid-dates', 'From date cannot be after To date'); + } + sendFile( { rid, diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index 63cf3ee7fa6a1..2fcc2a7b24516 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1881,6 +1881,7 @@ "error-invalid-custom-field-name": "Invalid custom field name. Use only letters, numbers, hyphens and underscores.", "error-invalid-custom-field-value": "Invalid value for __field__ field", "error-invalid-date": "Invalid date provided.", + "error-invalid-dates":"From date cannot be after To date", "error-invalid-description": "Invalid description", "error-invalid-domain": "Invalid domain", "error-invalid-email": "Invalid email __email__",