Skip to content

Commit

Permalink
refactor(NotificationUtils): Check for devices before rest of trip su…
Browse files Browse the repository at this point in the history
…rvey configs and sending request.
  • Loading branch information
binh-dam-ibigroup committed Oct 29, 2024
1 parent 8d92c4f commit 1381b06
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ public static String sendPush(OtpUser otpUser, String textTemplate, Object templ
* @param trip Trip about which the survey notification is about.
*/
public static String sendTripSurveyPush(OtpUser otpUser, MonitoredTrip trip) {
// If Push API/survey config properties aren't set, do nothing.
// Check devices first - No devices returns OK (favors E2E testing)
if (otpUser.pushDevices == 0) return "OK";

// If Push API/survey config properties aren't set, do nothing (will trigger warning log).
if (PUSH_API_KEY == null || PUSH_API_URL == null || TRIP_SURVEY_ID == null) return null;

Locale locale = I18nUtils.getOtpUserLocale(otpUser);
Expand All @@ -102,7 +105,7 @@ public static String sendTripSurveyPush(OtpUser otpUser, MonitoredTrip trip) {
org.opentripplanner.middleware.i18n.Message.TRIP_SURVEY_NOTIFICATION.get(locale),
tripTime
);
return otpUser.pushDevices > 0 ? sendPush(otpUser, body, trip.tripName, trip.id, TRIP_SURVEY_ID) : "OK";
return sendPush(otpUser, body, trip.tripName, trip.id, TRIP_SURVEY_ID);
}

/**
Expand Down

0 comments on commit 1381b06

Please sign in to comment.