send ad hoc alternative route notifications for recent uploaded trips

This commit is contained in:
2026-01-14 15:34:59 +01:00
parent ddbf925caf
commit 8ee6992f88
2 changed files with 80 additions and 5 deletions
@@ -52,4 +52,32 @@ public class NotificationSchedulerService {
notificationRepository.saveAll(notifications);
}
public void schedule(
Long userId,
Object dataBody,
NotificationType notificationType,
LocalTime earliestTimeOfDayToSend
) {
String dataBodyJson;
try {
dataBodyJson = objectMapper.writeValueAsString(dataBody);
} catch (Exception e) {
throw new RuntimeException("Failed to serialize notification data body", e);
}
User userProxy = entityManager.getReference(User.class, userId);
Notification notification = Notification.builder()
.user(userProxy)
.type(notificationType)
.data(dataBodyJson)
.earliestTimeOfDayToSend(earliestTimeOfDayToSend)
.status(NotificationStatus.PENDING)
.createdAt(LocalDateTime.now())
.failedSendAttempts(0)
.build();
notificationRepository.save(notification);
}
}