Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/uk/ac/cam/cl/dtg/isaac/dos/content/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class Notification extends Content {
private ExternalReference externalReference;
private Instant expiry;
private Instant startDate;

/**
* Notification object constructor taking a string value for the notification content.
Expand Down Expand Up @@ -79,4 +80,25 @@ public Instant getExpiry() {
public void setExpiry(final Instant expiry) {
this.expiry = expiry;
}


/**
* Gets the startDate.
*
* @return the startDate
*/
public Instant getStartDate() {
return startDate;
}

/**
* Sets the startDate.
*
* @param startDate the startDate to set
*/
public void setStartDate(final Instant startDate) {
this.startDate = startDate;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class NotificationDTO extends ContentDTO {
private ExternalReference externalReference;
private Instant expiry;
private Instant startDate;

/**
* Notification object constructor taking a string value for the notification content.
Expand Down Expand Up @@ -79,4 +80,23 @@ public Instant getExpiry() {
public void setExpiry(final Instant expiry) {
this.expiry = expiry;
}


/**
Comment thread
madhurabhujbal marked this conversation as resolved.
* Gets the startDate.
*
* @return the startDate
*/
public Instant getStartDate() {
return startDate;
Comment thread
madhurabhujbal marked this conversation as resolved.
}
Comment thread
madhurabhujbal marked this conversation as resolved.

/**
Comment thread
madhurabhujbal marked this conversation as resolved.
* Sets the startDate.
*
* @param startDate the startDate to set
*/
public void setStartDate(final Instant startDate) {
this.startDate = startDate;
Comment thread
madhurabhujbal marked this conversation as resolved.
}
Comment thread
madhurabhujbal marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public NotificationPicker(final GitContentManager contentManager, @Named(CONTENT

/**
* getAvailableNotificationsForUser.
*
* @param user to select notifications for.
* @return the list of content to show to the user.
* @throws ContentManagerException if something goes wrong looking up the content.
Expand Down Expand Up @@ -100,6 +99,11 @@ public List<ContentDTO> getAvailableNotificationsForUser(final RegisteredUserDTO
continue;
}

if (notification.getStartDate() != null && Instant.now().isBefore(notification.getStartDate())) {
// skip showing this notification yet
continue;
}

String roleTag = user.getRole().name().toLowerCase();
if (null == c.getTags() || !c.getTags().contains(roleTag)) {
// Skip irrelevant notifications
Expand Down
Loading