preparing to re-implement message settings
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
package de.srsoftware.umbrella.core.constants;
|
||||
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
public class Constants {
|
||||
@@ -17,6 +19,7 @@ public class Constants {
|
||||
public static final String NO_CACHE = "no-cache";
|
||||
public static final String NONE = "none";
|
||||
public static final String TABLE_SETTINGS = "settings";
|
||||
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
||||
public static final String UMBRELLA = "Umbrella";
|
||||
public static final String UTF8 = UTF_8.displayName();
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ public class EmailAddress {
|
||||
return obj instanceof EmailAddress other && Objects.equals(email,other.email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return email.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return email;
|
||||
|
||||
@@ -9,6 +9,8 @@ import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -17,8 +19,9 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Envelope {
|
||||
private Message message;
|
||||
private Set<User> receivers;
|
||||
private final Message message;
|
||||
private final Set<User> receivers;
|
||||
private final LocalDateTime time;
|
||||
|
||||
public Envelope(Message message, User receiver){
|
||||
this(message,new HashSet<>(Set.of(receiver)));
|
||||
@@ -27,6 +30,7 @@ public class Envelope {
|
||||
public Envelope(Message message, HashSet<User> receivers) {
|
||||
this.message = message;
|
||||
this.receivers = receivers;
|
||||
time = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +65,10 @@ public class Envelope {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public LocalDateTime time(){
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return format("{0} (to: {1}), subject: {2}",getClass().getSimpleName(),receivers.stream().map(User::email).map(EmailAddress::toString).collect(Collectors.joining(", ")),message.subject());
|
||||
|
||||
@@ -23,6 +23,17 @@ public class User {
|
||||
return email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof User user)) return false;
|
||||
return email.equals(user.email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return email.hashCode();
|
||||
}
|
||||
|
||||
public String language(){
|
||||
return lang;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user