Skip to content

Commit

Permalink
Update number of push devices sooner (per binh's PR comment).
Browse files Browse the repository at this point in the history
JymDyerIBI committed Aug 28, 2023
1 parent a3e08ab commit fb0df00
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -389,6 +389,12 @@ private void sendNotifications() {
// TODO: Bugsnag / delete monitored trip?
return;
}
// Update push notification devices count, which may change asynchronously
int numPushDevices = NotificationUtils.getPushInfo(otpUser.email);
if (numPushDevices != otpUser.pushDevices) {
otpUser.pushDevices = numPushDevices;
Persistence.otpUsers.replace(otpUser.id, otpUser);
}
// If the same notifications were just sent, there is no need to send the same notification.
// TODO: Should there be some time threshold check here based on lastNotificationTime?
if (previousJourneyState.lastNotifications.containsAll(notifications)) {
@@ -407,13 +413,6 @@ private void sendNotifications() {
boolean successPush = false;
boolean successSms = false;

// Update push notification devices count, which may change asynchronously
int numPushDevices = NotificationUtils.getPushInfo(otpUser.email);
if (numPushDevices != otpUser.pushDevices) {
otpUser.pushDevices = numPushDevices;
Persistence.otpUsers.replace(otpUser.id, otpUser);
}

if (otpUser.notificationChannel.contains(OtpUser.Notification.EMAIL)) {
successEmail = sendEmail(otpUser, templateData);
}

0 comments on commit fb0df00

Please sign in to comment.