Skip to content

Commit

Permalink
Rename email field in FcmUserDto
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Jul 19, 2024
1 parent d0a2a97 commit 20f1cc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
package org.radarbase.appserver.converter;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import org.radarbase.appserver.dto.fcm.FcmUserDto;
import org.radarbase.appserver.entity.User;
import org.radarbase.appserver.entity.UserMetrics;
Expand Down Expand Up @@ -54,7 +53,7 @@ public User dtoToEntity(FcmUserDto fcmUserDto) {
return new User()
.setFcmToken(fcmUserDto.getFcmToken())
.setSubjectId(fcmUserDto.getSubjectId())
.setEmailAddress(fcmUserDto.getEmailAddress())
.setEmailAddress(fcmUserDto.getEmail())
.setUserMetrics(getValidUserMetrics(fcmUserDto))
.setEnrolmentDate(fcmUserDto.getEnrolmentDate())
.setTimezone(fcmUserDto.getTimezone())
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/radarbase/appserver/dto/fcm/FcmUserDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class FcmUserDto implements Serializable {

@Email
// Email address of the user (optional, needed when sending notifications via email)
private String emailAddress;
private String email;

// The most recent time when the app was opened
private Instant lastOpened;
Expand Down Expand Up @@ -93,7 +93,7 @@ public FcmUserDto(User user) {
this.id = user.getId();
this.projectId = user.getProject().getProjectId();
this.subjectId = user.getSubjectId();
this.emailAddress = user.getEmailAddress();
this.email = user.getEmailAddress();
if (user.getUsermetrics() != null) {
this.lastOpened = user.getUsermetrics().getLastOpened();
this.lastDelivered = user.getUsermetrics().getLastDelivered();
Expand Down Expand Up @@ -136,8 +136,8 @@ public FcmUserDto setSubjectId(String subjectId) {
return this;
}

public FcmUserDto setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
public FcmUserDto setEmail(String email) {
this.email = email;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.radarbase.appserver.converter.UserConverter;
import org.radarbase.appserver.dto.fcm.FcmUserDto;
import org.radarbase.appserver.dto.fcm.FcmUsers;
import org.radarbase.appserver.dto.questionnaire.Schedule;
import org.radarbase.appserver.entity.Project;
import org.radarbase.appserver.entity.User;
import org.radarbase.appserver.exception.InvalidUserDetailsException;
Expand Down Expand Up @@ -156,7 +155,7 @@ public FcmUserDto saveUserInProject(FcmUserDto userDto) {
+ ". Please use Update endpoint if need to update the user");
}

if (sendEmailNotifications && (userDto.getEmailAddress() == null || userDto.getEmailAddress().isEmpty())) {
if (sendEmailNotifications && (userDto.getEmail() == null || userDto.getEmail().isEmpty())) {
log.warn("No email address was provided for new subject '{}'. The option to send notifications via email " +
"('radar.notification.email.enabled') will not work for this subject. Consider to provide a valid email " +
"address for subject '{}'.", userDto.getSubjectId());
Expand Down

0 comments on commit 20f1cc6

Please sign in to comment.