Merge branch 'feature/notifications' into dev
This commit is contained in:
@@ -225,6 +225,8 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
try {
|
||||
var envelopes = queue.getEnvelopesFor(receiver);
|
||||
envelopes.stream().map(Envelope::message).forEach(combined::merge);
|
||||
if (receiver instanceof UmbrellaUser) combined.addNote();
|
||||
|
||||
send(combined,date);
|
||||
envelopes.forEach(env -> queue.markRead(env.id(),receiver));
|
||||
} catch (Exception ex){
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.message.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.translator;
|
||||
import static de.srsoftware.umbrella.core.Util.dateTimeOf;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.TRACE;
|
||||
import static java.text.MessageFormat.format;
|
||||
@@ -20,6 +22,7 @@ public class CombinedMessage {
|
||||
private final List<Message<?>> mergedMessages = new ArrayList<>();
|
||||
private final Translatable subjectForCombinedMessage;
|
||||
private UmbrellaUser sender = null;
|
||||
public static final String SEPARATOR = "\n\n━━━━━━━━━━━━━━━━━━━━━\n\n";
|
||||
|
||||
public CombinedMessage(Translatable subjectForCombinedMessage, User receiver){
|
||||
LOG.log(DEBUG,"Creating combined message for {0}…",receiver);
|
||||
@@ -28,6 +31,19 @@ public class CombinedMessage {
|
||||
this.lang = receiver.language();
|
||||
}
|
||||
|
||||
public void addNote() {
|
||||
var text = translator().translate(lang,"You may change your notification settings at {base_url}/message/settings");
|
||||
combinedBody.append(SEPARATOR).append(text);
|
||||
}
|
||||
|
||||
public Set<Attachment> attachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public String body() {
|
||||
return combinedBody.toString();
|
||||
}
|
||||
|
||||
public void merge(Message<?> message) {
|
||||
LOG.log(TRACE,"Merging {0} into combined message…",message);
|
||||
|
||||
@@ -45,21 +61,13 @@ public class CombinedMessage {
|
||||
combinedSubject = subjectForCombinedMessage.translate(lang);
|
||||
// no break here, we need to append the subject and content
|
||||
default:
|
||||
combinedBody.append("\n\n━━━━━━━━━━━━━━━━━━━━━\n\n# ").append(message.sender()).append(" @ ").append(dateTimeOf(message.utcTime())).append("\n→ ").append(subject).append(":\n\n");
|
||||
combinedBody.append(SEPARATOR).append("# ").append(message.sender()).append(" @ ").append(dateTimeOf(message.utcTime())).append("\n→ ").append(subject).append(":\n\n");
|
||||
combinedBody.append(body);
|
||||
}
|
||||
if (message.attachments() != null) attachments.addAll(message.attachments());
|
||||
mergedMessages.add(message);
|
||||
}
|
||||
|
||||
public Set<Attachment> attachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public String body() {
|
||||
return combinedBody.toString();
|
||||
}
|
||||
|
||||
public List<Message<?>> messages() {
|
||||
return mergedMessages;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user