From 66460299b443ec3f1f78b78fa503dd2db282a969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adriana=20Ceri=C4=87?= <62163307+AdrianaCeric@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:41:30 -0500 Subject: [PATCH 01/15] feat(TripMonitorNotification): improve trip alert message --- .../middleware/models/TripMonitorNotification.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java b/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java index 5ea86804e..6d5fb2f1a 100644 --- a/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java +++ b/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java @@ -100,7 +100,7 @@ public static TripMonitorNotification createInitialReminderNotification(Monitore TripMonitorNotification notification = new TripMonitorNotification(); notification.type = NotificationType.INITIAL_REMINDER; // TODO: i18n and add itinerary details. - notification.body = String.format("Reminder for your upcoming trip at %s. We will let you know if anything changes.", trip.tripTime); + notification.body = String.format("Reminder for %s at %s.\nWe will notify you if anything changes.", trip.tripName, trip.tripTime); return notification; } @@ -119,15 +119,13 @@ private static String bodyFromAlerts( } // If there are any unseen alerts, include list of these. if (unseenAlerts.size() > 0) { - // TODO: Improve message. - body.append("New alerts found! They are:"); + body.append("\uD83D\uDD14 New alerts found:\n"); body.append(listFromAlerts(unseenAlerts, false)); } // If there are any resolved alerts, include list of these. if (resolvedAlerts.size() > 0) { if (body.length() > 0) body.append("\n"); - // TODO: Improve message. - body.append("Resolved alerts are:"); + body.append("Resolved alerts:"); body.append(listFromAlerts(resolvedAlerts, true)); } return body.toString(); From 77c15cab43db6b6ba14a33a095be0308fbd7d016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adriana=20Ceri=C4=87?= <62163307+AdrianaCeric@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:00:22 -0500 Subject: [PATCH 02/15] fix(TripMonitorNotification): add new line after resolved alerts --- .../middleware/models/TripMonitorNotification.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java b/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java index 6d5fb2f1a..dc13ee027 100644 --- a/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java +++ b/src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java @@ -125,7 +125,7 @@ private static String bodyFromAlerts( // If there are any resolved alerts, include list of these. if (resolvedAlerts.size() > 0) { if (body.length() > 0) body.append("\n"); - body.append("Resolved alerts:"); + body.append("Resolved alerts:\n"); body.append(listFromAlerts(resolvedAlerts, true)); } return body.toString(); From d083e447b635671d0002df096210271c1d0434a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adriana=20Ceri=C4=87?= <62163307+AdrianaCeric@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:05:30 -0500 Subject: [PATCH 03/15] fix(TripMonitorNotification): Make initial reminder not a list --- src/main/resources/templates/MonitoredTripHtml.ftl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/resources/templates/MonitoredTripHtml.ftl b/src/main/resources/templates/MonitoredTripHtml.ftl index 1876a405b..7ca412671 100644 --- a/src/main/resources/templates/MonitoredTripHtml.ftl +++ b/src/main/resources/templates/MonitoredTripHtml.ftl @@ -8,11 +8,19 @@ <#macro EmailMain>
${notification.body}
+ #if> +View all of your saved trips in ${OTP_UI_NAME}.
${notification.body}
- #if> + <#list notifications as notification> + <#if notification.type == "INITIAL_REMINDER"> +${notification.body}
+ #if> + #list>View all of your saved trips in Trip Planner.
\n\n \n You're receiving this email because you're subscribed to notifications through Trip Planner. You can manage that subscription here.\n \n
\nThis is the initial reminder text
\n\nView all of your saved trips in Trip Planner.
\n\n \n You're receiving this email because you're subscribed to notifications through Trip Planner. You can manage that subscription here.\n \n
\n
+ * When the tests are first run, the {@code com.zenika.snapshotmatcher.SnapshotMatcher} class will create JSON snapshot
+ * files in {@code resources/snapshots/org/opentripplanner/middleware} which are used thereafter to compare with the
+ * results of the template files. If you change any {@code *.ftl} files you will need to delete their corresponding
+ * snapshot files, run the tests to create new snapshots, and then commit those files along with new template files.
+ */
public class TemplateUtilsTest extends OtpMiddlewareTestEnvironment {
/**
* A parameterized test that checks whether various templates render in a way that matches a snapshot. The name of
@@ -104,4 +112,4 @@ private static