notification preferences fix

This commit is contained in:
Timo Bejan 2021-11-03 10:56:26 +02:00
parent 615e5bba55
commit f9f9a03186
2 changed files with 2 additions and 4 deletions

View File

@ -14,7 +14,6 @@ import java.util.List;
@AllArgsConstructor
public class NotificationPreferences {
private String userId;
private boolean inAppNotificationsEnabled;
private boolean emailNotificationsEnabled;
private EmailNotificationType emailNotificationType;

View File

@ -19,11 +19,10 @@ public class NotificationPreferencesPersistenceService {
@Transactional
public void setNotificationPreference(String userId, NotificationPreferences notification) {
notificationPreferencesRepository.findById(userId)
.ifPresentOrElse(n -> {
BeanUtils.copyProperties(notification, n);
}, () -> {
.ifPresentOrElse(n -> BeanUtils.copyProperties(notification, n), () -> {
NotificationPreferencesEntity notificationPreferencesEntity = new NotificationPreferencesEntity();
BeanUtils.copyProperties(notification, notificationPreferencesEntity);
notificationPreferencesEntity.setUserId(userId);
notificationPreferencesRepository.save(notificationPreferencesEntity);
});
}