Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c351440c8 |
+1
-1
@@ -1,5 +1,5 @@
|
||||
FROM alpine:3.22
|
||||
LABEL Maintainer "Stephan Richter"
|
||||
LABEL Maintainer "Stephan Richter <s.richter@srsoftware.de>"
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
RUN apk add bash npm
|
||||
|
||||
@@ -18,7 +18,6 @@ dependencies{
|
||||
implementation(project(":core"))
|
||||
implementation(project(":documents"))
|
||||
implementation(project(":files"))
|
||||
implementation(project(":journal"))
|
||||
implementation(project(":legacy"))
|
||||
implementation(project(":markdown"))
|
||||
implementation(project(":messages"))
|
||||
@@ -53,7 +52,6 @@ tasks.jar {
|
||||
":core:jar",
|
||||
":documents:jar",
|
||||
":files:jar",
|
||||
":journal:jar",
|
||||
":legacy:jar",
|
||||
":markdown:jar",
|
||||
":messages:jar",
|
||||
|
||||
@@ -16,7 +16,6 @@ import de.srsoftware.umbrella.core.Util;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.documents.DocumentApi;
|
||||
import de.srsoftware.umbrella.files.FileModule;
|
||||
import de.srsoftware.umbrella.journal.JournalModule;
|
||||
import de.srsoftware.umbrella.legacy.*;
|
||||
import de.srsoftware.umbrella.markdown.MarkdownApi;
|
||||
import de.srsoftware.umbrella.message.MessageSystem;
|
||||
@@ -64,10 +63,9 @@ public class Application {
|
||||
|
||||
var server = HttpServer.create(new InetSocketAddress(port), 0);
|
||||
try {
|
||||
new Translations(config).bindPath("/api/translations").on(server);
|
||||
new JournalModule(config).bindPath("/api/journal").on(server);
|
||||
new Translations().bindPath("/api/translations").on(server);
|
||||
new MessageApi().bindPath("/api/bus").on(server);
|
||||
new MessageSystem(config).bindPath("/api/message").on(server);
|
||||
new MessageSystem(config);
|
||||
new UserModule(config).bindPath("/api/user").on(server);
|
||||
new TagModule(config).bindPath("/api/tags").on(server);
|
||||
new BookmarkApi(config).bindPath("/api/bookmark").on(server);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ subprojects {
|
||||
implementation("de.srsoftware:tools.mime:1.1.4")
|
||||
implementation("de.srsoftware:tools.logging:1.3.2")
|
||||
implementation("de.srsoftware:tools.optionals:1.0.0")
|
||||
implementation("de.srsoftware:tools.util:2.1.1")
|
||||
implementation("de.srsoftware:tools.util:2.0.4")
|
||||
implementation("org.json:json:20240303")
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ package de.srsoftware.umbrella.messagebus;
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
|
||||
public interface EventListener {
|
||||
void onEvent(Event<?> event);
|
||||
void onEvent(Event event);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class EventQueue extends LinkedList<Event<?>> implements AutoCloseable, EventListener {
|
||||
public class EventQueue extends LinkedList<Event> implements AutoCloseable, EventListener {
|
||||
|
||||
private final InetSocketAddress addr;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EventQueue extends LinkedList<Event<?>> implements AutoCloseable, E
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event<?> event) {
|
||||
public void onEvent(Event event) {
|
||||
System.getLogger(addr.toString()).log(System.Logger.Level.INFO,"adding event to queue of {1}: {0}",event.eventType(),addr);
|
||||
add(event);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class MessageBus {
|
||||
private static final MessageBus SINGLETON = new MessageBus();
|
||||
private final Set<EventListener> listeners = new HashSet<>();
|
||||
private static MessageBus SINGLETON = new MessageBus();
|
||||
private Set<EventListener> listeners = new HashSet<>();
|
||||
|
||||
private MessageBus(){}
|
||||
|
||||
|
||||
@@ -1,84 +1,38 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static java.util.Optional.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.USER;
|
||||
|
||||
import de.srsoftware.tools.Diff;
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.model.Translatable;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public abstract class Event<Payload extends Mappable> {
|
||||
|
||||
public enum EventType {
|
||||
CREATE,
|
||||
MEMBER_ADDED,
|
||||
UPDATE,
|
||||
DELETE;
|
||||
|
||||
}
|
||||
private UmbrellaUser initiator;
|
||||
|
||||
private final UmbrellaUser initiator;
|
||||
private final String module;
|
||||
private final Payload payload;
|
||||
private final EventType eventType;
|
||||
private final Map<String, Object> oldData;
|
||||
|
||||
private String module;
|
||||
private Payload payload;
|
||||
private EventType eventType;
|
||||
public Event(UmbrellaUser initiator, String module, Payload payload, EventType type){
|
||||
this.initiator = initiator;
|
||||
this.module = module;
|
||||
this.payload = payload;
|
||||
this.eventType = type;
|
||||
this.oldData = null;
|
||||
}
|
||||
|
||||
public Event(UmbrellaUser initiator, String module, Payload payload, Map<String, Object> oldData){
|
||||
this.initiator = initiator;
|
||||
this.module = module;
|
||||
this.payload = payload;
|
||||
this.eventType = EventType.UPDATE;
|
||||
this.oldData = oldData;
|
||||
public String eventType(){
|
||||
return eventType.toString();
|
||||
}
|
||||
|
||||
public abstract Collection<UmbrellaUser> audience();
|
||||
|
||||
public abstract Translatable describe();
|
||||
|
||||
private Map<String, Object> dropMarkdown(Map<String, Object> map) {
|
||||
var result = new HashMap<String, Object>();
|
||||
for (var entry : map.entrySet()){
|
||||
var v = entry.getValue();
|
||||
if (v instanceof Map<?,?> m && m.containsKey(RENDERED) && m.get(SOURCE) instanceof String s) v=s;
|
||||
result.put(entry.getKey(),v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Optional<String> diff(){
|
||||
return oldData == null ? empty() : of(Diff.MapDiff.diff(filter(oldData),filter(payload.toMap())));
|
||||
}
|
||||
|
||||
|
||||
public EventType eventType(){
|
||||
return eventType;
|
||||
}
|
||||
|
||||
protected Map<String,Object> filter(Map<String,Object> map){
|
||||
return dropMarkdown(map);
|
||||
}
|
||||
|
||||
public boolean isIntendedFor(UmbrellaUser user){
|
||||
return audience().contains(user);
|
||||
}
|
||||
|
||||
public UmbrellaUser initiator(){
|
||||
return initiator;
|
||||
}
|
||||
public abstract boolean isIntendedFor(UmbrellaUser user);
|
||||
|
||||
public String json(){
|
||||
Class<?> clazz = payload.getClass();
|
||||
@@ -94,17 +48,7 @@ public abstract class Event<Payload extends Mappable> {
|
||||
return new JSONObject(map).toString();
|
||||
}
|
||||
|
||||
public String module(){
|
||||
return module;
|
||||
}
|
||||
|
||||
protected Map<String, Object> oldData() {
|
||||
return oldData;
|
||||
}
|
||||
|
||||
public Payload payload(){
|
||||
return payload;
|
||||
}
|
||||
|
||||
public abstract Translatable subject();
|
||||
}
|
||||
|
||||
@@ -1,72 +1,15 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.projectService;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.taskService;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Module.PROJECT;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.MEMBER_ADDED;
|
||||
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import de.srsoftware.umbrella.core.model.Project;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
|
||||
|
||||
public class ProjectEvent extends Event<Project>{
|
||||
private final UmbrellaUser newMember;
|
||||
|
||||
public ProjectEvent(UmbrellaUser initiator, Project project, EventType type){
|
||||
super(initiator, PROJECT, project, type);
|
||||
newMember = null;
|
||||
}
|
||||
|
||||
public ProjectEvent(UmbrellaUser initiator, Project project, Map<String, Object> oldData){
|
||||
super(initiator, PROJECT, project, oldData);
|
||||
newMember = null;
|
||||
}
|
||||
|
||||
public ProjectEvent(UmbrellaUser initiator, Project project, UmbrellaUser newMember){
|
||||
super(initiator, PROJECT, project, MEMBER_ADDED);
|
||||
this.newMember = newMember;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UmbrellaUser> audience() {
|
||||
return payload().members().values().stream().map(Member::user).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return switch (eventType()){
|
||||
case CREATE -> describeCreate();
|
||||
case DELETE -> t("The project '{project}' has been deleted by {user}", Field.PROJECT, payload().name(), USER, initiator().name());
|
||||
case MEMBER_ADDED -> describeMemberAdded();
|
||||
case UPDATE -> describeUpdate();
|
||||
};
|
||||
}
|
||||
|
||||
private Translatable describeCreate() {
|
||||
var head = t("You have been added to the new project '{project}', created by {user}:\n\n{body}", Field.PROJECT, payload().name(), BODY, payload().description(), USER, initiator().name());
|
||||
return t("{head}\n\n{link}","head",head,"link",link());
|
||||
}
|
||||
|
||||
private Translatable describeMemberAdded() {
|
||||
var head = t("'{name}' has been added to '{object}' by '{user}'.",NAME,newMember.name(),Field.OBJECT,payload().name(),USER,initiator().name());
|
||||
return t("{head}\n\n{link}","head",head,"link",link());
|
||||
}
|
||||
|
||||
private Translatable describeUpdate() {
|
||||
var head = t("Changes in project '{project}':\n\n{body}",Field.PROJECT,payload().name(),BODY,diff().orElse(""));
|
||||
return t("{head}\n\n{link}","head",head,"link",link());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> filter(Map<String, Object> map) {
|
||||
map.remove(MEMBERS);
|
||||
return super.filter(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,16 +19,4 @@ public class ProjectEvent extends Event<Project>{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Translatable link() {
|
||||
return t("You can view/edit this project at {base_url}/project/{id}/view",ID,payload().id());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable subject() {
|
||||
return switch (eventType()){
|
||||
case CREATE -> t("The project '{project}' has been created", Field.PROJECT, payload().name());
|
||||
case DELETE -> t("The project '{project}' has been deleted",Field.PROJECT, payload().name());
|
||||
case MEMBER_ADDED, UPDATE -> t("Project '{project}' was edited",Field.PROJECT,payload().name());
|
||||
};
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -2,84 +2,15 @@
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.projectService;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.taskService;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Module.TASK;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.MEMBER_ADDED;
|
||||
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import de.srsoftware.umbrella.core.model.Task;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
|
||||
|
||||
public class TaskEvent extends Event<Task>{
|
||||
private final UmbrellaUser newMember;
|
||||
|
||||
public TaskEvent(UmbrellaUser initiator, Task task, EventType type){
|
||||
super(initiator, TASK, task, type);
|
||||
newMember = null;
|
||||
}
|
||||
|
||||
public TaskEvent(UmbrellaUser initiator, Task task, Map<String, Object> oldData){
|
||||
super(initiator, TASK, task, oldData);
|
||||
newMember = null;
|
||||
}
|
||||
|
||||
public TaskEvent(UmbrellaUser initiator, Task task, UmbrellaUser newMember) {
|
||||
super(initiator, TASK, task, MEMBER_ADDED);
|
||||
this.newMember = newMember;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UmbrellaUser> audience() {
|
||||
return payload().members().values().stream().map(Member::user).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return switch (eventType()){
|
||||
case CREATE -> describeCreate();
|
||||
case DELETE -> t("The task '{task}' has been deleted by {user}",Field.TASK, payload().name(), USER, initiator().name());
|
||||
case MEMBER_ADDED -> describeMemberAdded();
|
||||
case UPDATE -> describeUpdate();
|
||||
};
|
||||
}
|
||||
|
||||
private Translatable describeCreate() {
|
||||
String parentName = null;
|
||||
var pid = payload().parentTaskId();
|
||||
if (pid != null) {
|
||||
var parent = taskService().load(List.of(pid)).get(pid);
|
||||
if (parent != null) parentName = parent.name();
|
||||
}
|
||||
if (parentName == null){
|
||||
var project = projectService().load(payload().projectId());
|
||||
if (project != null) parentName = project.name();
|
||||
}
|
||||
if (parentName == null) parentName = "?";
|
||||
var head = t("'{task}' has been added to '{object}':\n\n{body}", Field.TASK, payload().name(), OBJECT, parentName, BODY, payload().description());
|
||||
return t("{head}\n\n{link}","head",head,"link",link());
|
||||
}
|
||||
|
||||
private Translatable describeMemberAdded() {
|
||||
var head = t("'{name}' has been added to '{object}' by '{user}'.",NAME,newMember.name(), OBJECT,payload().name(),USER,initiator().name());
|
||||
return t("{head}\n\n{link}","head",head,"link",link());
|
||||
}
|
||||
|
||||
private Translatable describeUpdate() {
|
||||
var head = t("Changes in task '{task}':\n\n{body}",Field.TASK,payload().name(),BODY,diff().orElse(""));
|
||||
return t("{head}\n\n{link}","head",head,"link",link());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> filter(Map<String, Object> map) {
|
||||
map.remove(MEMBERS);
|
||||
return super.filter(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,16 +20,4 @@ public class TaskEvent extends Event<Task>{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Translatable link() {
|
||||
return t("You can view/edit this task at {base_url}/task/{id}/view",ID,payload().id());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable subject() {
|
||||
return switch (eventType()){
|
||||
case CREATE -> t("The task '{task}' has been created", Field.TASK, payload().name());
|
||||
case DELETE -> t("The task '{task}' has been deleted",Field.TASK, payload().name());
|
||||
case MEMBER_ADDED, UPDATE -> t("Task '{task}' was edited",Field.TASK,payload().name());
|
||||
};
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.OBJECT;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.USER;
|
||||
import static de.srsoftware.umbrella.core.constants.Module.WIKI;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class WikiEvent extends Event<WikiPage>{
|
||||
public WikiEvent(UmbrellaUser initiator, WikiPage page, EventType type){
|
||||
super(initiator, WIKI, page, type);
|
||||
}
|
||||
|
||||
public WikiEvent(UmbrellaUser initiator, WikiPage page, Map<String, Object> oldData){
|
||||
super(initiator, WIKI, page, oldData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UmbrellaUser> audience() {
|
||||
return payload().members().values().stream().map(Member::user).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return diff().map(UnTranslatable::new).map(Translatable.class::cast)
|
||||
.orElseGet(() -> t("[TODO: {object}.describe]",OBJECT,this.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable subject() {
|
||||
return t("{user} edited {object}",USER,initiator(),OBJECT,payload());
|
||||
}
|
||||
}
|
||||
@@ -74,4 +74,5 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ package de.srsoftware.umbrella.core.constants;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class Constants {
|
||||
|
||||
private Constants(){
|
||||
@@ -19,7 +17,6 @@ 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();
|
||||
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
package de.srsoftware.umbrella.core.constants;
|
||||
|
||||
public class Field {
|
||||
public static final String ACTION = "action";
|
||||
public static final String ADDRESS = "address";
|
||||
public static final String ALLOWED_STATES = "allowed_states";
|
||||
public static final String AMOUNT = "amount";
|
||||
public static final String ATTACHMENTS = "attachments";
|
||||
public static final String AUTHORIZATION = "Authorization";
|
||||
|
||||
public static final String BASE_URL = "umbrella.base_url";
|
||||
public static final String BANK_ACCOUNT = "bank_account";
|
||||
public static final String BODY = "body";
|
||||
|
||||
@@ -68,10 +66,8 @@ public class Field {
|
||||
|
||||
public static final String HASH = "hash";
|
||||
public static final String HEAD = "head";
|
||||
public static final String HOURS = "hours";
|
||||
|
||||
public static final String ID = "id";
|
||||
public static final String INSTANTLY = "instantly";
|
||||
public static final String ITEM = "item";
|
||||
public static final String ITEM_CODE = "item_code";
|
||||
|
||||
@@ -115,7 +111,6 @@ public class Field {
|
||||
public static final String PRICE = "single_price";
|
||||
public static final String PRICE_FORMAT = "price_format";
|
||||
public static final String PRIORITY = "priority";
|
||||
public static final String PROJECT = "project";
|
||||
public static final String PROJECT_ID = "project_id";
|
||||
public static final String PROPERTIES = "properties";
|
||||
|
||||
@@ -127,7 +122,6 @@ public class Field {
|
||||
public static final String SENDER = "sender";
|
||||
public static final String SETTINGS = "settings";
|
||||
public static final String SHOW_CLOSED = "show_closed";
|
||||
public static final String SILENT = "silent";
|
||||
public static final String SOURCE = "source";
|
||||
public static final String START_DATE = "start_date";
|
||||
public static final String START_TIME = "start_time";
|
||||
|
||||
@@ -7,5 +7,5 @@ public class Module {
|
||||
public static final String PROJECT = "project";
|
||||
public static final String TASK = "task";
|
||||
public static final String USER = "user";
|
||||
public static final String WIKI = "wiki";
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class Path {
|
||||
public static final String PROPERTIES = "properties";
|
||||
public static final String PROPERTY = "property";
|
||||
|
||||
public static final String READ = "read";
|
||||
public static final String REDIRECT = "redirect";
|
||||
|
||||
public static final String SEARCH = "search";
|
||||
|
||||
@@ -23,11 +23,6 @@ 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,7 +9,6 @@ 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;
|
||||
@@ -18,9 +17,8 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Envelope {
|
||||
private final Message message;
|
||||
private final Set<User> receivers;
|
||||
private final LocalDateTime time;
|
||||
private Message message;
|
||||
private Set<User> receivers;
|
||||
|
||||
public Envelope(Message message, User receiver){
|
||||
this(message,new HashSet<>(Set.of(receiver)));
|
||||
@@ -29,7 +27,6 @@ public class Envelope {
|
||||
public Envelope(Message message, HashSet<User> receivers) {
|
||||
this.message = message;
|
||||
this.receivers = receivers;
|
||||
time = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,17 +49,6 @@ public class Envelope {
|
||||
return new Envelope(message,receivers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (!(o instanceof Envelope envelope)) return false;
|
||||
return message.equals(envelope.message) && time.equals(envelope.time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * message.hashCode() + time.hashCode();
|
||||
}
|
||||
|
||||
public boolean isFor(User receiver) {
|
||||
return receivers.contains(receiver);
|
||||
}
|
||||
@@ -75,10 +61,6 @@ 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());
|
||||
|
||||
@@ -9,13 +9,12 @@ import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import java.util.*;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public record Message(UmbrellaUser sender, Translatable subject, Translatable body, List<Attachment> attachments) {
|
||||
public record Message(UmbrellaUser sender, String subject, String body, Map<String,String> fills, List<Attachment> attachments) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Message message)) return false;
|
||||
@@ -44,7 +43,7 @@ public record Message(UmbrellaUser sender, Translatable subject, Translatable bo
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Message(sender,new UnTranslatable(subject),new UnTranslatable(body),attachments);
|
||||
return new Message(sender,subject,body,null, attachments);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Task implements Mappable {
|
||||
private boolean noIndex, showClosed;
|
||||
private final Map<Long, Member> members;
|
||||
private final Set<String> dirtyFields = new HashSet<>();
|
||||
private final Set<String> tags = new HashSet<>();
|
||||
|
||||
|
||||
public Task (long id, long projectId, Long parentTaskId, String name, String description, int status, Double estimatedTime, LocalDate start, LocalDate dueDate, boolean showClosed, boolean noIndex, Map<Long,Member> members, int priority){
|
||||
this.id = id;
|
||||
@@ -218,16 +218,6 @@ public class Task implements Mappable {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Task tags(Collection<String> newValue){
|
||||
tags.clear();
|
||||
if (newValue != null) tags.addAll(newValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<String> tags(){
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
var map = new HashMap<String,Object>();
|
||||
@@ -250,7 +240,7 @@ public class Task implements Mappable {
|
||||
map.put(REQUIRED_TASKS_IDS,requiredTasksIds);
|
||||
map.put(SHOW_CLOSED,showClosed);
|
||||
map.put(TOTAL_PRIO,totalPrio());
|
||||
map.put(TAGS,tags);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.tools.Optionals.*;
|
||||
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Translatable {
|
||||
protected final String message;
|
||||
private final Map<String, Object> fills;
|
||||
private final String message;
|
||||
private Map<String, Object> fills;
|
||||
private final HashMap<String,String> translated = new HashMap<>();
|
||||
|
||||
public Translatable(String message, Map<String,Object> fills){
|
||||
@@ -41,7 +39,7 @@ public class Translatable {
|
||||
}
|
||||
|
||||
public String translate(String language){
|
||||
var translation = language == null ? null : translated.get(language);
|
||||
var translation = language != null ? translated.get(language) : null;
|
||||
if (translation == null){
|
||||
var translatedFills = new HashMap<String,String>();
|
||||
if (fills != null) {
|
||||
@@ -56,7 +54,7 @@ public class Translatable {
|
||||
}
|
||||
}
|
||||
translation = ModuleRegistry.translator().translate(language,message,translatedFills);
|
||||
if (allSet(language, translation)) translated.put(language,translation);
|
||||
if (translation != null) translated.put(language,translation);
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
|
||||
|
||||
public class UnTranslatable extends Translatable{
|
||||
public UnTranslatable(String message) {
|
||||
super(message, null);
|
||||
}
|
||||
|
||||
public String translate(String language){
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -23,17 +23,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -157,11 +157,6 @@ public class WikiPage implements Mappable {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public int version(){
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ public class DocumentApi extends BaseHandler implements DocumentService {
|
||||
LOG.log(WARNING,e);
|
||||
}
|
||||
var attachment = new Attachment(doc.number()+".pdf",rendered.mimeType(),rendered.bytes());
|
||||
var message = new Message(user,new UnTranslatable(subject),new UnTranslatable(content),List.of(attachment));
|
||||
var message = new Message(user,subject,content,null,List.of(attachment));
|
||||
var envelope = new Envelope(message,new User(doc.customer().shortName(),new EmailAddress(email),doc.customer().language()));
|
||||
postBox().send(envelope);
|
||||
db.save(doc.set(SENT));
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
import Kanban from "./routes/project/Kanban.svelte";
|
||||
import Login from "./Components/Login.svelte";
|
||||
import Messages from "./routes/message/Messages.svelte";
|
||||
import MsgSettings from "./routes/message/Settings.svelte";
|
||||
import Menu from "./Components/Menu.svelte";
|
||||
import NewPage from "./routes/wiki/AddPage.svelte";
|
||||
import Notes from "./routes/notes/Index.svelte";
|
||||
@@ -92,8 +91,7 @@
|
||||
<Route path="/document/:id/send" component={SendDoc} />
|
||||
<Route path="/document/:id/view" component={ViewDoc} />
|
||||
<Route path="/files/*" component={FileIndex} />
|
||||
<Route path="/message" component={Messages} />
|
||||
<Route path="/message/settings" component={MsgSettings} />
|
||||
<Route path="/message/settings" component={Messages} />
|
||||
<Route path="/notes" component={Notes} />
|
||||
<Route path="/project" component={ProjectList} />
|
||||
<Route path="/project/add" component={ProjectAdd} />
|
||||
|
||||
@@ -69,7 +69,6 @@ onMount(fetchModules);
|
||||
<a href="/wiki" {onclick} class="wiki">{t('wiki')}</a>
|
||||
<a href="/contact" {onclick} class="contact">{t('contacts')}</a>
|
||||
<a href="/stock" {onclick} class="stock">{t('stock')}</a>
|
||||
<a href="/message" {onclick} class="message">{t('messages')}</a>
|
||||
{#if user.id == 2}
|
||||
<a href="https://svelte.dev/tutorial/svelte/state" target="_blank">{t('tutorial')}</a>
|
||||
{/if}
|
||||
|
||||
@@ -1,95 +1,7 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { t } from '../../translations.svelte';
|
||||
import { api, get, patch } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
|
||||
let router = useTinyRouter();
|
||||
let messages = [];
|
||||
let timer = null;
|
||||
|
||||
async function display(hash){
|
||||
const url = api(`message/${hash}`);
|
||||
const res = await get(url);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
const json = await res.json();
|
||||
if (timer) clearTimeout(timer);
|
||||
for (let i in messages){
|
||||
if (messages[i].hash == hash){
|
||||
messages[i].body = json.body;
|
||||
timer = setTimeout(() => {mark_read(hash)}, 2000);
|
||||
} else {
|
||||
delete messages[i].body;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
async function load(){
|
||||
const url = api('message');
|
||||
const res = await get(url);
|
||||
if (res.ok){
|
||||
messages = await res.json();
|
||||
yikes();
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
async function mark_read(hash){
|
||||
timer = null;
|
||||
const url = api(`message/read/${hash}`);
|
||||
const res = await patch(url);
|
||||
if (res.ok) {
|
||||
for (let i in messages){
|
||||
if (messages[i].hash == hash) messages[i].read = true;
|
||||
}
|
||||
yikes();
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
function showSettings(){
|
||||
router.navigate("message/settings");
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
</script>
|
||||
|
||||
<fieldset>
|
||||
<legend>{t('messages')} <button onclick={showSettings}>{t('settings')}</button></legend>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t('timestamp')}</th>
|
||||
<th>{t('initiator')}</th>
|
||||
<th>{t('subject')}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each messages as message}
|
||||
<tr class="message-{message.hash}" onclick={ev => display(message.hash)}>
|
||||
<td>
|
||||
{#if message.read}→ {/if}
|
||||
{message.timestamp}
|
||||
</td>
|
||||
<td>{message.sender}</td>
|
||||
<td>{message.subject}</td>
|
||||
</tr>
|
||||
{#if message.body}
|
||||
<tr class="message-{message.hash} body">
|
||||
<td></td>
|
||||
<td colspan="2">
|
||||
<pre>{message.body.trim()}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
<legend>{t('messages')}</legend>
|
||||
</fieldset>
|
||||
@@ -1,201 +0,0 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
import { api, get, patch } from '../../urls.svelte';
|
||||
import { error, warn, yikes } from '../../warn.svelte';
|
||||
|
||||
let instant = false;
|
||||
let silent = false;
|
||||
let at8 = false;
|
||||
let at9 = false;
|
||||
let at10 = false;
|
||||
let at11 = false;
|
||||
let at12 = false;
|
||||
let at13 = false;
|
||||
let at14 = true;
|
||||
let at15 = false;
|
||||
let at16 = false;
|
||||
let at17 = false;
|
||||
let at18 = false;
|
||||
let at19 = false;
|
||||
let at20 = false;
|
||||
let at21 = false;
|
||||
let at22 = false;
|
||||
|
||||
function delivery(mode){
|
||||
if (mode){
|
||||
silent = false;
|
||||
} else {
|
||||
instant = false;
|
||||
}
|
||||
at8 = at9 = at10 = at11 = at12 = at13 = at14 = at15 = at16 = at17 = at18 = at19 = at20 = at21 = at22 = false;
|
||||
saveTimes();
|
||||
}
|
||||
|
||||
async function loadSettings(){
|
||||
const url = api('message/settings');
|
||||
const res = await get(url);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
const json = await res.json();
|
||||
if (json.hours){
|
||||
at8 = json.hours.includes(8);
|
||||
at9 = json.hours.includes(9);
|
||||
at10 = json.hours.includes(10);
|
||||
at11 = json.hours.includes(11);
|
||||
at12 = json.hours.includes(12);
|
||||
at13 = json.hours.includes(13);
|
||||
at14 = json.hours.includes(14);
|
||||
at15 = json.hours.includes(15);
|
||||
at16 = json.hours.includes(16);
|
||||
at17 = json.hours.includes(17);
|
||||
at18 = json.hours.includes(18);
|
||||
at19 = json.hours.includes(19);
|
||||
at20 = json.hours.includes(20);
|
||||
at21 = json.hours.includes(21);
|
||||
at22 = json.hours.includes(22);
|
||||
instant = false;
|
||||
silent = !(at8 || at9 || at10 || at11 || at12 || at13 || at14 || at15 || at16 || at17 || at18 || at19 || at20 || at21 || at22);
|
||||
} else {
|
||||
instant = json.instantly;
|
||||
silent = !instant;
|
||||
at8 = at9 = at10 = at11 = at12 = at13 = at14 = at15 = at16 = at17 = at18 = at19 = at20 = at21 = at22 = false;
|
||||
}
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveTimes(){
|
||||
let data = {
|
||||
instantly : instant,
|
||||
hours : []
|
||||
}
|
||||
if (at8) data.hours.push(8);
|
||||
if (at9) data.hours.push(9);
|
||||
if (at10) data.hours.push(10);
|
||||
if (at11) data.hours.push(11);
|
||||
if (at12) data.hours.push(12);
|
||||
if (at13) data.hours.push(13);
|
||||
if (at14) data.hours.push(14);
|
||||
if (at15) data.hours.push(15);
|
||||
if (at16) data.hours.push(16);
|
||||
if (at17) data.hours.push(17);
|
||||
if (at18) data.hours.push(18);
|
||||
if (at19) data.hours.push(19);
|
||||
if (at20) data.hours.push(20);
|
||||
if (at21) data.hours.push(21);
|
||||
if (at22) data.hours.push(22);
|
||||
let url = api('message/settings');
|
||||
let res = await patch(url,data);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
warn(t('saved'));
|
||||
setTimeout(yikes,2500);
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
function selectTime(ev){
|
||||
instant = false;
|
||||
silent = !(at8 || at9 || at10 || at11 || at12 || at13 || at14 || at15 || at16 || at17 || at18 || at19 || at20 || at21 || at22);
|
||||
saveTimes();
|
||||
}
|
||||
|
||||
onMount(loadSettings)
|
||||
</script>
|
||||
|
||||
<fieldset class="message settings">
|
||||
<legend>{t('notification settings')}</legend>
|
||||
<p>{t('When shall messages be delivered?')}</p>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<label>
|
||||
<input type="checkbox" onchange={ev => delivery(true)} bind:checked={instant} />{t('instantly')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{t('collect messages and send them at')}
|
||||
</td>
|
||||
<td>
|
||||
⎧<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎨<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎩
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at8} />{t('8:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at9} />{t('9:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at10} />{t('10:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at11} />{t('11:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at12} />{t('noon')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at13} />{t('1:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at14} />{t('2:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at15} />{t('3:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at16} />{t('4:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at17} />{t('5:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at18} />{t('6:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at19} />{t('7:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at20} />{t('8:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at21} />{t('9:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at22} />{t('10:00 pm')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<label>
|
||||
<input type="checkbox" onchange={ev => delivery(false)} bind:checked={silent} />{t('i don`t want to receive email notifications!')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
@@ -14,7 +14,7 @@
|
||||
<legend>
|
||||
{t('your_profile')}
|
||||
<button onclick={() => router.navigate(`/user/${user.id}/edit`)}>{t('edit')}</button>
|
||||
<button onclick={() => router.navigate(`/message/settings`)}>{t('notification settings')}</button>
|
||||
<!-- <button onclick={() => router.navigate(`/message/settings`)}>{t('settings')}</button> -->
|
||||
|
||||
</legend>
|
||||
<table>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { api, eventStream } from '../../urls.svelte';
|
||||
import { api } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
import { user } from '../../user.svelte';
|
||||
@@ -13,7 +13,6 @@
|
||||
import TagList from '../tags/TagList.svelte';
|
||||
|
||||
let detail = $state(false);
|
||||
let eventSource = null;
|
||||
let { key, version } = $props();
|
||||
let page = $state({});
|
||||
let router = useTinyRouter();
|
||||
@@ -28,10 +27,6 @@
|
||||
return patch({members:newMembers});
|
||||
}
|
||||
|
||||
function connectToBus(){
|
||||
eventSource = eventStream(null,handleUpdateEvent,null);
|
||||
}
|
||||
|
||||
async function dropMember(member){
|
||||
var id = member.user.id;
|
||||
let newMembers = JSON.parse(JSON.stringify(page.members));
|
||||
@@ -56,11 +51,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleUpdateEvent(evt){
|
||||
let json = JSON.parse(evt.data);
|
||||
if (json.wikipage) loadContent(json.wikipage);
|
||||
}
|
||||
|
||||
function nonMember(json){
|
||||
return !page.members[json.id];
|
||||
}
|
||||
@@ -80,15 +70,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
function loadContent(json){
|
||||
json.versions.sort((a,b)=>b-a);
|
||||
page = { ...json };
|
||||
}
|
||||
|
||||
async function loadJson(res){
|
||||
async function loadContent(res){
|
||||
if (res.ok){
|
||||
let json = await res.json();
|
||||
loadContent(json);
|
||||
json.versions.sort((a,b)=>b-a);
|
||||
page = { ...json };
|
||||
yikes();
|
||||
return true;
|
||||
} else {
|
||||
@@ -102,7 +88,7 @@
|
||||
if (version) path += `/version/${version}`;
|
||||
const url = api(path);
|
||||
const res = await fetch(url,{credentials:'include'});
|
||||
loadJson(res);
|
||||
loadContent(res);
|
||||
}
|
||||
|
||||
function onclick(e){
|
||||
@@ -119,7 +105,7 @@
|
||||
method:'PATCH',
|
||||
body:JSON.stringify(data)
|
||||
});
|
||||
return loadJson(res);
|
||||
return loadContent(res);
|
||||
}
|
||||
|
||||
async function patchGuestPermissions(ev){
|
||||
@@ -144,7 +130,6 @@
|
||||
}
|
||||
|
||||
$effect(loadPage);
|
||||
onMount(connectToBus);
|
||||
</script>
|
||||
{#if page && page.versions}
|
||||
<div class="wiki page">
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
description = "Umbrella : Journal"
|
||||
|
||||
dependencies{
|
||||
implementation(project(":bus"))
|
||||
implementation(project(":core"))
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.journal;
|
||||
|
||||
public class Constants {
|
||||
public static final String CONFIG_DATABASE = "umbrella.modules.journal.database";
|
||||
|
||||
public static final String ERROR_WRITE_EVENT = "Failed to write {0} event of {1} to journal!";
|
||||
public static final String TABLE_JOURNAL = "journal";
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.journal;
|
||||
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
|
||||
public interface JournalDb {
|
||||
void logEvent(Event<?> event);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.journal;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingField;
|
||||
import static de.srsoftware.umbrella.journal.Constants.CONFIG_DATABASE;
|
||||
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.messagebus.EventListener;
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
|
||||
|
||||
public class JournalModule extends BaseHandler implements EventListener {
|
||||
|
||||
private final JournalDb journalDb;
|
||||
|
||||
public JournalModule(Configuration config){
|
||||
super();
|
||||
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingField(CONFIG_DATABASE));
|
||||
journalDb = new SqliteDb(connect(dbFile));
|
||||
ModuleRegistry.add(this);
|
||||
messageBus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event<?> event) {
|
||||
LOG.log(DEBUG,"{0} @ {1} (by {2})",event.eventType(),event.module(),event.initiator().name());
|
||||
journalDb.logEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.journal;
|
||||
|
||||
import static de.srsoftware.tools.jdbc.Query.insertInto;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.failedToCreateTable;
|
||||
import static de.srsoftware.umbrella.journal.Constants.ERROR_WRITE_EVENT;
|
||||
import static de.srsoftware.umbrella.journal.Constants.TABLE_JOURNAL;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.umbrella.core.BaseDb;
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SqliteDb extends BaseDb implements JournalDb{
|
||||
public SqliteDb(Connection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
protected int createTables() {
|
||||
int currentVersion = createSettingsTable();
|
||||
switch (currentVersion){
|
||||
case 0:
|
||||
createJournalTable();
|
||||
}
|
||||
|
||||
return setCurrentVersion(1);
|
||||
}
|
||||
|
||||
private void createJournalTable() {
|
||||
var sql = """
|
||||
CREATE TABLE IF NOT EXISTS {0} (
|
||||
{1} INTEGER PRIMARY KEY,
|
||||
{2} INTEGER,
|
||||
{3} VARCHAR(255) NOT NULL,
|
||||
{4} VARCHAR(16) NOT NULL,
|
||||
{5} TEXT
|
||||
);
|
||||
""";
|
||||
sql = format(sql,TABLE_JOURNAL,ID,USER_ID,MODULE,ACTION,DESCRIPTION);
|
||||
try {
|
||||
db.prepareStatement(sql).execute();
|
||||
} catch (SQLException e) {
|
||||
throw failedToCreateTable(TABLE_JOURNAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logEvent(Event<?> event) {
|
||||
try {
|
||||
insertInto(TABLE_JOURNAL,USER_ID,MODULE,ACTION,DESCRIPTION)
|
||||
.values(event.initiator().id(), event.module(), event.eventType(), event.describe())
|
||||
.execute(db).close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(ERROR_WRITE_EVENT,event.eventType(),event.initiator().name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
description = "Umbrella : Message subsystem"
|
||||
|
||||
dependencies{
|
||||
implementation(project(":bus"))
|
||||
implementation(project(":core"))
|
||||
implementation("com.sun.mail:jakarta.mail:2.0.1")
|
||||
implementation("org.bitbucket.b_c:jose4j:0.9.6")
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package de.srsoftware.umbrella.message;
|
||||
|
||||
public class Constants {
|
||||
public static final String AUTH = "mail.smtp.auth";
|
||||
|
||||
public static final String CONFIG_DB = "umbrella.modules.message.database";
|
||||
public static final String CONFIG_SMTP_HOST = "umbrella.modules.message.smtp.host";
|
||||
@@ -11,13 +10,11 @@ public class Constants {
|
||||
public static final String CONFIG_SMTP_USER = "umbrella.modules.message.smtp.user";
|
||||
|
||||
public static final String DEBUG_ADDREESS = "umbrella.modules.message.debug_address";
|
||||
public static final String ENVELOPE_FROM = "mail.smtp.from";
|
||||
public static final String FIELD_MESSAGES = "messages";
|
||||
public static final String FIELD_HOST = "host";
|
||||
public static final String FIELD_PORT = "port";
|
||||
public static final String HOST = "mail.smtp.host";
|
||||
public static final String PORT = "mail.smtp.port";
|
||||
public static final String SSL = "mail.smtp.ssl.enable";
|
||||
public static final String SMTP_AUTH = "mail.smtp.auth";
|
||||
public static final String SMTP_HOST = "mail.smtp.host";
|
||||
public static final String SMTP_FROM = "mail.smtp.from";
|
||||
public static final String SMTP_PORT = "mail.smtp.port";
|
||||
public static final String SMTP_SSL = "mail.smtp.ssl.enable";
|
||||
public static final String SUBMISSION = "submission";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,39 +1,23 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.message;
|
||||
|
||||
import static de.srsoftware.tools.PathHandler.CONTENT_TYPE;
|
||||
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
|
||||
import static de.srsoftware.umbrella.core.constants.Constants.TIME_FORMATTER;
|
||||
import static de.srsoftware.umbrella.core.constants.Constants.UTF8;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Path.READ;
|
||||
import static de.srsoftware.umbrella.core.constants.Path.SETTINGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Text.LONG;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidField;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingConfig;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.message.Constants.*;
|
||||
import static de.srsoftware.umbrella.message.model.Schedule.schedule;
|
||||
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.tools.Path;
|
||||
import de.srsoftware.tools.SessionToken;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.api.PostBox;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Envelope;
|
||||
import de.srsoftware.umbrella.core.model.Token;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import de.srsoftware.umbrella.core.model.User;
|
||||
import de.srsoftware.umbrella.message.model.*;
|
||||
import de.srsoftware.umbrella.messagebus.EventListener;
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
import de.srsoftware.umbrella.message.model.CombinedMessage;
|
||||
import jakarta.activation.DataHandler;
|
||||
import jakarta.mail.Message.RecipientType;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Transport;
|
||||
@@ -41,14 +25,11 @@ import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
import jakarta.mail.util.ByteArrayDataSource;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class MessageSystem extends BaseHandler implements PostBox, EventListener {
|
||||
public class MessageSystem implements PostBox {
|
||||
public static final System.Logger LOG = System.getLogger(MessageSystem.class.getSimpleName());
|
||||
private final Timer timer = new Timer();
|
||||
|
||||
@@ -78,6 +59,9 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
timer.schedule(this,date.getTime());
|
||||
LOG.log(INFO,"Scheduled {0} at {1}",getClass().getSimpleName(),date.getTime());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
private final String from,host,user,pass;
|
||||
private final int port;
|
||||
@@ -93,8 +77,8 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
debugAddress = config.get(DEBUG_ADDREESS).map(Object::toString).orElse(null);
|
||||
port = config.get(CONFIG_SMTP_PORT,587);
|
||||
host = config.get(CONFIG_SMTP_HOST).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.host not configured!"));
|
||||
user = config.get(CONFIG_SMTP_USER).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.user not configured!"));
|
||||
pass = config.get(CONFIG_SMTP_PASS).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.pass not configured!"));
|
||||
user = config.get(CONFIG_SMTP_USER).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.user not configured!"));
|
||||
pass = config.get(CONFIG_SMTP_PASS).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.pass not configured!"));
|
||||
from = user;
|
||||
ModuleRegistry.add(this);
|
||||
new SubmissionTask(8).schedule();
|
||||
@@ -104,110 +88,12 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
new SubmissionTask(16).schedule();
|
||||
new SubmissionTask(18).schedule();
|
||||
new SubmissionTask(20).schedule();
|
||||
messageBus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGet(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
try {
|
||||
Optional<Token> token = SessionToken.from(ex).map(Token::of);
|
||||
var user = ModuleRegistry.userService().loadUser(token);
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var head = path.pop();
|
||||
return switch (head){
|
||||
case null -> listMessages(ex,user.get());
|
||||
case SETTINGS -> getSettings(ex,user.get());
|
||||
default -> {
|
||||
try {
|
||||
yield getMessage(ex,user.get(),Integer.parseInt(head));
|
||||
} catch (NumberFormatException ignored) {
|
||||
|
||||
}
|
||||
yield super.doGet(path, ex);
|
||||
}
|
||||
};
|
||||
} catch (NumberFormatException e){
|
||||
return sendContent(ex,HTTP_BAD_REQUEST,"Invalid project id");
|
||||
} catch (UmbrellaException e){
|
||||
return send(ex,e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPatch(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
try {
|
||||
Optional<Token> token = SessionToken.from(ex).map(Token::of);
|
||||
var user = ModuleRegistry.userService().loadUser(token);
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var head = path.pop();
|
||||
return switch (head){
|
||||
case SETTINGS -> patchSettings(ex,user.get());
|
||||
case READ -> patchState(ex,user.get(),path.pop());
|
||||
default -> super.doGet(path,ex);
|
||||
};
|
||||
} catch (NumberFormatException e){
|
||||
return sendContent(ex,HTTP_BAD_REQUEST,"Invalid project id");
|
||||
} catch (UmbrellaException e){
|
||||
return send(ex,e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getMessage(HttpExchange ex, UmbrellaUser user, int hash) throws IOException {
|
||||
var envelope = queue.stream()
|
||||
.filter(msg -> msg.isFor(user))
|
||||
.filter(msg -> msg.hashCode() == hash)
|
||||
.findFirst();
|
||||
if (envelope.isPresent()) return sendMessage(ex, user, envelope.get());
|
||||
return notFound(ex);
|
||||
}
|
||||
|
||||
private boolean getSettings(HttpExchange ex, UmbrellaUser user) throws IOException {
|
||||
return sendContent(ex,db.getSettings(user));
|
||||
}
|
||||
|
||||
private boolean listMessages(HttpExchange ex, UmbrellaUser user) throws IOException {
|
||||
var messages = queue.stream().filter(e -> e.isFor(user)).map(e -> summary(e, user.language())).toList();
|
||||
return sendContent(ex,messages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event<?> event) {
|
||||
for (var user : event.audience()){
|
||||
if (debugAddress != null && !debugAddress.equals(user.email().toString())) continue;
|
||||
var message = new de.srsoftware.umbrella.core.model.Message(event.initiator(),event.subject(),event.describe(),null);
|
||||
var envelope = new Envelope(message,user);
|
||||
send(envelope);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean patchSettings(HttpExchange ex, UmbrellaUser user) throws IOException {
|
||||
var json = json(ex);
|
||||
Settings settings = null;
|
||||
if (json.has(INSTANTLY) && json.get(INSTANTLY) instanceof Boolean b && b){
|
||||
settings = new Instantly();
|
||||
} else {
|
||||
if (json.has(HOURS) && json.get(HOURS) instanceof JSONArray hrs){
|
||||
var hours = hrs.toList().stream().filter(v -> v instanceof Integer).map(Integer.class::cast).toList();
|
||||
settings = schedule(hours);
|
||||
} else settings = new Silent();
|
||||
}
|
||||
return sendContent(ex,db.update(user,settings));
|
||||
}
|
||||
|
||||
private boolean patchState(HttpExchange ex, UmbrellaUser user, String path) {
|
||||
try {
|
||||
var hash = Integer.parseInt(path);
|
||||
var envelope = queue.stream().filter(env -> env.hashCode() == hash).findFirst().orElse(null);
|
||||
if (envelope != null){
|
||||
envelope.receivers().remove(user);
|
||||
return sendMessage(ex,user,envelope);
|
||||
}
|
||||
return notFound(ex);
|
||||
} catch (NumberFormatException | IOException e) {
|
||||
throw invalidField(HASH,LONG);
|
||||
}
|
||||
public void send(Envelope envelope) {
|
||||
queue.add(envelope);
|
||||
new Thread(() -> processMessages(null)).start();
|
||||
}
|
||||
|
||||
private synchronized void processMessages(Integer scheduledHour) {
|
||||
@@ -230,12 +116,14 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
var date = new Date();
|
||||
|
||||
for (var receiver : dueRecipients){
|
||||
var combined = new CombinedMessage(t("Collected messages"),receiver);
|
||||
BiFunction<String,Map<String,String>,String> translateFunction = (text,fills) -> ModuleRegistry.translator().translate(receiver.language(),text,fills);
|
||||
|
||||
var combined = new CombinedMessage("Collected messages",translateFunction);
|
||||
var envelopes = queue.stream().filter(env -> env.isFor(receiver)).toList();
|
||||
for (var envelope : envelopes) combined.merge(envelope.message());
|
||||
|
||||
try {
|
||||
send(combined,date);
|
||||
send(combined,receiver,date);
|
||||
for (var envelope : envelopes){
|
||||
var audience = envelope.receivers();
|
||||
audience.remove(receiver);
|
||||
@@ -251,29 +139,25 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
if (scheduledHour != null) new SubmissionTask(scheduledHour).schedule();
|
||||
}
|
||||
|
||||
private boolean sendMessage(HttpExchange ex, UmbrellaUser user, Envelope envelope) throws IOException {
|
||||
var message = envelope.message();
|
||||
var sender = message.sender().name();
|
||||
var subject = message.subject().translate(user.language());
|
||||
var body = message.body().translate(user.language());
|
||||
return sendContent(ex,Map.of(
|
||||
SENDER,sender,
|
||||
SUBJECT,subject,
|
||||
BODY,body
|
||||
));
|
||||
private Session session() {
|
||||
if (session == null){
|
||||
Properties props = new Properties();
|
||||
props.put(SMTP_HOST, host);
|
||||
props.put(SMTP_PORT, port);
|
||||
props.put(SMTP_AUTH, true);
|
||||
props.put(SMTP_SSL, true);
|
||||
props.put(SMTP_FROM,from);
|
||||
session = Session.getInstance(props);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
private static JSONObject summary(Envelope envelope, String lang) {
|
||||
var sender = envelope.message().sender().name();
|
||||
var subject = envelope.message().subject().translate(lang);
|
||||
var time = envelope.time().format(TIME_FORMATTER);
|
||||
var hash = envelope.hashCode();
|
||||
return new JSONObject(Map.of(SENDER,sender,SUBJECT,subject,TIMESTAMP,time,HASH,hash));
|
||||
public void setDebugAddress(String newVal) {
|
||||
this.debugAddress = newVal;
|
||||
}
|
||||
|
||||
|
||||
private void send(CombinedMessage message, Date date) throws MessagingException {
|
||||
var receiver = message.receiver();
|
||||
private void send(CombinedMessage message, User receiver, Date date) throws MessagingException {
|
||||
LOG.log(TRACE,"Sending combined message to {0}…",receiver);
|
||||
session = session();
|
||||
MimeMessage msg = new MimeMessage(session);
|
||||
@@ -284,7 +168,7 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
msg.setSubject(message.subject(), UTF8);
|
||||
msg.setSentDate(date);
|
||||
var toEmail = debugAddress != null ? debugAddress : receiver.email().toString();
|
||||
msg.setRecipients(RecipientType.TO, toEmail);
|
||||
msg.setRecipients(Message.RecipientType.TO, toEmail);
|
||||
|
||||
if (message.attachments().isEmpty()){
|
||||
msg.setText(message.body(), UTF8);
|
||||
@@ -303,32 +187,10 @@ public class MessageSystem extends BaseHandler implements PostBox, EventListener
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOG.log(TRACE, "Message to {0} is ready…", receiver);
|
||||
Transport.send(msg,user,pass);
|
||||
LOG.log(DEBUG, "Sent message to {0}.", receiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Envelope envelope) {
|
||||
queue.add(envelope);
|
||||
new Thread(() -> processMessages(null)).start();
|
||||
}
|
||||
|
||||
private Session session() {
|
||||
if (session == null){
|
||||
Properties props = new Properties();
|
||||
props.put(HOST, host);
|
||||
props.put(PORT, port);
|
||||
props.put(AUTH, true);
|
||||
props.put(SSL, true);
|
||||
props.put(ENVELOPE_FROM,from);
|
||||
session = Session.getInstance(props);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setDebugAddress(String newVal) {
|
||||
this.debugAddress = newVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,19 +8,19 @@ import static de.srsoftware.umbrella.core.constants.Constants.TABLE_SETTINGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.message.model.Schedule.schedule;
|
||||
import static de.srsoftware.umbrella.message.model.Settings.Times;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.umbrella.core.constants.Text;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import de.srsoftware.umbrella.message.model.Instantly;
|
||||
import de.srsoftware.umbrella.message.model.Settings;
|
||||
import de.srsoftware.umbrella.message.model.Silent;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SqliteMessageDb implements MessageDb{
|
||||
private static final System.Logger LOG = System.getLogger(SqliteMessageDb.class.getSimpleName());
|
||||
@@ -100,19 +100,21 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
|
||||
private Settings toSettings(ResultSet rs) throws SQLException {
|
||||
var submission = rs.getString(VALUE);
|
||||
if (submission.trim().equalsIgnoreCase(INSTANTLY)) return new Instantly();
|
||||
try {
|
||||
var times = Arrays.stream(submission.split(",")).map(Integer::parseInt).toList();
|
||||
return schedule(times);
|
||||
} catch (NumberFormatException nfe){
|
||||
return new Silent();
|
||||
var parts = submission.split(",");
|
||||
var times = new HashSet<Times>();
|
||||
for (var part : parts) try {
|
||||
times.add(Times.valueOf(part));
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.log(WARNING,"encountered {0}, which is not a valid Times enumeration value!",part);
|
||||
}
|
||||
return new Settings(times);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings update(UmbrellaUser user, Settings settings) throws UmbrellaException {
|
||||
var times = settings.times().stream().map(Times::toString).collect(Collectors.joining(","));
|
||||
try {
|
||||
replaceInto(TABLE_SUBMISSIONS, USER_ID, VALUE).values(user.id(),settings.toString()).execute(db).close();
|
||||
replaceInto(TABLE_SUBMISSIONS, USER_ID, VALUE).values(user.id(),times).execute(db).close();
|
||||
return settings;
|
||||
} catch (SQLException e) {
|
||||
throw failedToStoreObject("submission data").causedBy(e);
|
||||
|
||||
@@ -5,31 +5,33 @@ import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.TRACE;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
import de.srsoftware.umbrella.core.model.Attachment;
|
||||
import de.srsoftware.umbrella.core.model.Message;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class CombinedMessage {
|
||||
private static final System.Logger LOG = System.getLogger(CombinedMessage.class.getSimpleName());
|
||||
|
||||
private final Set<Attachment> attachments = new HashSet<>();
|
||||
private final StringBuilder combinedBody = new StringBuilder();
|
||||
private final User receiver;
|
||||
private String combinedSubject = null;
|
||||
private final List<Message> mergedMessages = new ArrayList<>();
|
||||
private final Translatable subjectForCombinedMessage;
|
||||
private final String subjectForCombinedMessage;
|
||||
private final BiFunction<String,Map<String,String>,String> translate;
|
||||
private UmbrellaUser sender = null;
|
||||
|
||||
public CombinedMessage(Translatable subjectForCombinedMessage, User receiver){
|
||||
public CombinedMessage(String subjectForCombinedMessage, BiFunction<String, Map<String,String>,String> translateFunction){
|
||||
LOG.log(DEBUG,"Creating combined message…");
|
||||
this.subjectForCombinedMessage = subjectForCombinedMessage;
|
||||
this.receiver = receiver;
|
||||
translate = translateFunction;
|
||||
}
|
||||
|
||||
public void merge(Message message) {
|
||||
LOG.log(TRACE,"Merging {0} into combined message…",message);
|
||||
var lang = receiver.language();
|
||||
var body = message.body().translate(lang);
|
||||
var subject = message.subject().translate(lang);
|
||||
var body = translate.apply(message.body(),message.fills());
|
||||
var subject = translate.apply(message.subject(),message.fills());
|
||||
switch (mergedMessages.size()){
|
||||
case 0:
|
||||
combinedBody.append(body);
|
||||
@@ -38,7 +40,7 @@ public class CombinedMessage {
|
||||
break;
|
||||
case 1:
|
||||
combinedBody.insert(0,format("# {0}:\n# {1}:\n\n",sender,subject)); // insert sender and subject of first message right before the body of the first message
|
||||
combinedSubject = subjectForCombinedMessage.translate(lang);
|
||||
combinedSubject = subjectForCombinedMessage;
|
||||
// no break here, we need to append the subject and content
|
||||
default:
|
||||
combinedBody.append("\n\n# ").append(message.sender()).append(":\n");
|
||||
@@ -57,14 +59,6 @@ public class CombinedMessage {
|
||||
return combinedBody.toString();
|
||||
}
|
||||
|
||||
public List<Message> messages() {
|
||||
return mergedMessages;
|
||||
}
|
||||
|
||||
public User receiver(){
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public UmbrellaUser sender() {
|
||||
return sender;
|
||||
}
|
||||
@@ -73,10 +67,7 @@ public class CombinedMessage {
|
||||
return combinedSubject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
var body = body();
|
||||
if (body.length()>100) body = body.substring(0,99)+"…";
|
||||
return format("{0} for {1} ({2}): {3}",getClass().getSimpleName(),receiver.email(),subject(),body);
|
||||
public List<Message> messages() {
|
||||
return mergedMessages;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.message.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.INSTANTLY;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Instantly implements Settings{
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(INSTANTLY,true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendAt(Integer scheduledHour) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return INSTANTLY;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.message.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.HOURS;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class Schedule implements Settings{
|
||||
|
||||
private final HashSet<Integer> hours;
|
||||
|
||||
private Schedule(Collection<Integer> hours){
|
||||
this.hours = new HashSet<>(hours);
|
||||
}
|
||||
|
||||
public static Settings schedule(Collection<Integer> hours){
|
||||
return hours == null || hours.isEmpty() ? new Silent() : new Schedule(hours);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendAt(Integer scheduledHour) {
|
||||
return scheduledHour != null && hours.contains(scheduledHour);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(HOURS,hours);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return hours.stream().map(Object::toString).collect(joining(","));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,38 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.message.model;
|
||||
|
||||
import static de.srsoftware.umbrella.message.Constants.SUBMISSION;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public record Settings(Set<Times> times) implements Mappable {
|
||||
|
||||
public enum Times{
|
||||
INSTANTLY,
|
||||
AT8,
|
||||
AT10,
|
||||
AT12,
|
||||
AT14,
|
||||
AT16,
|
||||
AT18,
|
||||
AT20;
|
||||
|
||||
public boolean matches(int hour){
|
||||
if (this == INSTANTLY) return false;
|
||||
return Integer.parseInt(toString().substring(2)) == hour;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendAt(Integer scheduledHour) {
|
||||
return times.contains(Times.INSTANTLY) || (scheduledHour != null && times.stream().anyMatch(time -> time.matches(scheduledHour)));
|
||||
}
|
||||
|
||||
|
||||
public interface Settings extends Mappable {
|
||||
boolean sendAt(Integer scheduledHour);
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(SUBMISSION,times);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.message.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.SILENT;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Silent implements Settings{
|
||||
@Override
|
||||
public boolean sendAt(Integer scheduledHour) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(SILENT,true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "silent";
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,7 @@ import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.SETTINGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.TAGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Module.PROJECT;
|
||||
import static de.srsoftware.umbrella.core.constants.Path.LIST;
|
||||
import static de.srsoftware.umbrella.core.constants.Path.SEARCH;
|
||||
import static de.srsoftware.umbrella.core.constants.Path.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Text.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Permission.*;
|
||||
@@ -19,6 +18,7 @@ import static de.srsoftware.umbrella.core.model.Status.PREDEFINED;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.CREATE;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.UPDATE;
|
||||
import static de.srsoftware.umbrella.project.Constants.CONFIG_DATABASE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
|
||||
@@ -50,12 +50,11 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
||||
ModuleRegistry.add(this);
|
||||
}
|
||||
|
||||
private UmbrellaUser addMember(Project project, long userId) {
|
||||
private void addMember(Project project, long userId) {
|
||||
var user = userService().loadUser(userId);
|
||||
var member = new Member(user,READ_ONLY);
|
||||
project.members().put(userId,member);
|
||||
project.dirty(MEMBERS);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,15 +215,13 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
||||
private boolean patchProject(HttpExchange ex, long projectId, UmbrellaUser user) throws IOException, UmbrellaException {
|
||||
var project = loadMembers(projectDb.load(projectId));
|
||||
if (!project.hasMember(user)) throw notAmember(t(PROJECT_WITH_ID,ID,project.name()));
|
||||
var old = project.toMap();
|
||||
var json = json(ex);
|
||||
UmbrellaUser newMember = null;
|
||||
if (json.has(DROP_MEMBER) && json.get(DROP_MEMBER) instanceof Number id) dropMember(project,id.longValue());
|
||||
if (json.has(MEMBERS) && json.get(MEMBERS) instanceof JSONObject memberJson) patchMembers(project,memberJson);
|
||||
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) newMember = addMember(project,num.longValue());
|
||||
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) addMember(project,num.longValue());
|
||||
|
||||
project = projectDb.save(project.patch(json), user);
|
||||
messageBus().dispatch(newMember != null ? new ProjectEvent(user,project,newMember) : new ProjectEvent(user,project, old));
|
||||
messageBus().dispatch(new ProjectEvent(user,project, UPDATE));
|
||||
return sendContent(ex,project.toMap());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Errors.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Constants.TABLE_SETTINGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.PROJECT;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.TYPE;
|
||||
import static de.srsoftware.umbrella.core.constants.Text.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
|
||||
@@ -21,5 +21,3 @@ include("translations")
|
||||
include("user")
|
||||
include("web")
|
||||
include("wiki")
|
||||
|
||||
include("journal")
|
||||
@@ -7,7 +7,6 @@ import static de.srsoftware.umbrella.core.ModuleRegistry.*;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_NOT_IMPLEMENTED;
|
||||
import static de.srsoftware.umbrella.core.Util.mapValues;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.PROJECT;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.TAGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.TASKS;
|
||||
import static de.srsoftware.umbrella.core.constants.Module.TASK;
|
||||
@@ -19,6 +18,7 @@ import static de.srsoftware.umbrella.core.model.Permission.OWNER;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.CREATE;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.UPDATE;
|
||||
import static de.srsoftware.umbrella.project.Constants.PERMISSIONS;
|
||||
import static de.srsoftware.umbrella.task.Constants.*;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
@@ -48,6 +48,22 @@ import org.json.JSONObject;
|
||||
|
||||
public class TaskModule extends BaseHandler implements TaskService {
|
||||
|
||||
private static class TaggedTask extends Task{
|
||||
private final Collection<String> tags;
|
||||
|
||||
public TaggedTask(Task task, Collection<String> tags) {
|
||||
super(task.id(), task.projectId(), task.parentTaskId(), task.name(), task.description(), task.status(), task.estimatedTime(), task.start(), task.dueDate(), task.showClosed(), task.noIndex(), task.members(), task.priority());
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
var map = super.toMap();
|
||||
map.put(TAGS,tags);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
private final TaskDb taskDb;
|
||||
|
||||
public TaskModule(Configuration config) throws UmbrellaException {
|
||||
@@ -57,12 +73,11 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
ModuleRegistry.add(this);
|
||||
}
|
||||
|
||||
private UmbrellaUser addMember(Task task, long userId) {
|
||||
private void addMember(Task task, long userId) {
|
||||
var user = userService().loadUser(userId);
|
||||
var member = new Member(user, READ_ONLY);
|
||||
task.members().put(userId, member);
|
||||
task.dirty(MEMBERS);
|
||||
return user;
|
||||
}
|
||||
|
||||
private boolean deleteTask(HttpExchange ex, long taskId, UmbrellaUser user) throws IOException {
|
||||
@@ -326,19 +341,16 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
|
||||
private boolean patchTask(HttpExchange ex, long taskId, UmbrellaUser user) throws IOException {
|
||||
var task = loadMembers(taskDb.load(taskId));
|
||||
var old = task.toMap();
|
||||
var member = task.members().get(user.id());
|
||||
if (member == null || member.permission() == READ_ONLY) throw forbidden("You are not a allowed to edit {object}!", OBJECT, task.name());
|
||||
var json = json(ex);
|
||||
if (json.has(PARENT_TASK_ID) && json.get(PARENT_TASK_ID) instanceof Number ptid && newParentIsSubtask(task, ptid.longValue())) throw forbidden("Task must not be sub-task of itself.");
|
||||
|
||||
UmbrellaUser newMember = null;
|
||||
if (json.has(DROP_MEMBER) && json.get(DROP_MEMBER) instanceof Number id) dropMember(task, id.longValue());
|
||||
if (json.has(MEMBERS) && json.get(MEMBERS) instanceof JSONObject memberJson) patchMembers(task, memberJson);
|
||||
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) newMember = addMember(task, num.longValue());
|
||||
|
||||
task = taskDb.save(task.patch(json)).tags(tagService().getTags(TASK, taskId, user));
|
||||
messageBus().dispatch(newMember != null ? new TaskEvent(user, task, newMember) : new TaskEvent(user, task, old));
|
||||
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) addMember(task, num.longValue());
|
||||
if (json.has(PARENT_TASK_ID) && json.get(PARENT_TASK_ID) instanceof Number ptid && newParentIsSubtask(task, ptid.longValue())) throw forbidden("Task must not be sub-task of itself.");
|
||||
taskDb.save(task.patch(json));
|
||||
var tagList = tagService().getTags(TASK, taskId, user);
|
||||
messageBus().dispatch(new TaskEvent(user,new TaggedTask(task,tagList), UPDATE));
|
||||
return sendContent(ex, task);
|
||||
}
|
||||
|
||||
@@ -399,8 +411,8 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
if ((tagList == null || tagList.isEmpty())) tagList = tagService().getTags(PROJECT, projectId, user);
|
||||
if (tagList != null && !tagList.isEmpty()) tagService().save(TASK, task.id(), null, tagList);
|
||||
task = loadMembers(task);
|
||||
task.tags(tagList);
|
||||
messageBus().dispatch(new TaskEvent(user, task, CREATE));
|
||||
|
||||
messageBus().dispatch(new TaskEvent(user,new TaggedTask(task,tagList), CREATE));
|
||||
return sendContent(ex, task);
|
||||
}
|
||||
|
||||
@@ -441,6 +453,6 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
}
|
||||
|
||||
private Map<Long, Task> addTags(Map<Long, Task> taskList, Map<Long, ? extends Collection<String>> tags) {
|
||||
return taskList.values().stream().map(task -> task.tags(tags.get(task.id()))).collect(Collectors.toMap(Task::id, t -> t));
|
||||
return taskList.values().stream().map(task -> new TaggedTask(task, tags.get(task.id()))).collect(Collectors.toMap(Task::id, t -> t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.translations;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.BASE_URL;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingField;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.tools.Path;
|
||||
import de.srsoftware.tools.PathHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
@@ -17,21 +14,15 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Translations extends PathHandler implements Translator {
|
||||
private static final System.Logger LOG = System.getLogger("Translations");
|
||||
private final String baseUrl;
|
||||
|
||||
private HashMap<String, JSONObject> translations = new HashMap<>();
|
||||
|
||||
public Translations(Configuration config) {
|
||||
public Translations() {
|
||||
ModuleRegistry.add(this);
|
||||
Optional<String> baseUrl = config.get(BASE_URL);
|
||||
if (baseUrl.isEmpty()) throw missingField(BASE_URL);
|
||||
this.baseUrl = baseUrl.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +69,7 @@ public class Translations extends PathHandler implements Translator {
|
||||
if (fills != null) for (var entry : fills.entrySet()) {
|
||||
translated = translated.replaceAll("\\{"+entry.getKey()+"}",entry.getValue());
|
||||
}
|
||||
return translated.replaceAll("\\{base_url}",baseUrl);
|
||||
return translated;
|
||||
} catch (IOException e) {
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
{
|
||||
"8:00 am": "8:00 Uhr",
|
||||
"9:00 am": "9:00 Uhr",
|
||||
"10:00 am": "10:00 Uhr",
|
||||
"11:00 am": "11:00 Uhr",
|
||||
"1:00 pm": "13:00 Uhr",
|
||||
"2:00 pm": "14:00 Uhr",
|
||||
"3:00 pm": "15:00 Uhr",
|
||||
"4:00 pm": "16:00 Uhr",
|
||||
"5:00 pm": "17:00 Uhr",
|
||||
"6:00 pm": "18:00 Uhr",
|
||||
"7:00 pm": "19:00 Uhr",
|
||||
"8:00 pm": "20:00 Uhr",
|
||||
"9:00 pm": "21:00 Uhr",
|
||||
"10:00 pm": "22:00 Uhr",
|
||||
|
||||
"abort": "abbrechen",
|
||||
"actions": "Aktionen",
|
||||
"add_login_service": "Login-Service anlegen",
|
||||
@@ -33,15 +18,12 @@
|
||||
"by": "von",
|
||||
|
||||
"cancel": "abbrechen",
|
||||
"Changes in project '{project}':\n\n{body}": "Änderungen an Projekt '{project}':\n\n{body}",
|
||||
"Changes in task '{task}':\n\n{body}": "Änderungen an Aufgabe '{task}':\n\n{body}",
|
||||
"choose_type": "Typ wählen",
|
||||
"click_to_edit": "Anklicken zum Bearbeiten",
|
||||
"client_id": "Client-ID",
|
||||
"client_secret": "Client-Geheimnis",
|
||||
"close_settings": "Einstellungen schließen",
|
||||
"code": "Code",
|
||||
"collect messages and send them at": "Nachriten sammeln und zustellen um",
|
||||
"color": "Farbe",
|
||||
"connect_service": "mit Service verbinden",
|
||||
"connected_services": "verbundene Login-Services",
|
||||
@@ -161,6 +143,7 @@
|
||||
|
||||
"given_name": "Vorname",
|
||||
"go": "los!",
|
||||
"go_to_url_to_reset_password": "Um ein neues Passwort zu erhalten, öffnen Sie bitte den folgenden Link: {url}",
|
||||
"gross_sum": "Brutto-Summe",
|
||||
|
||||
"head": "Kopf-Text",
|
||||
@@ -170,11 +153,9 @@
|
||||
"hours": "Stunden",
|
||||
|
||||
"id": "Id",
|
||||
"i don`t want to receive email notifications!": "Ich möchte keine Email-Benachrichtigungen!",
|
||||
"impersonate": "zu Nutzer wechseln",
|
||||
"IMPERSONATE": "Nutzer wechseln",
|
||||
"index_page": "Aufgabenübersicht",
|
||||
"instantly": "sofort",
|
||||
"invert_filter": "Filter umkehren",
|
||||
"invoice": "Rechnung",
|
||||
"item": "Artikel",
|
||||
@@ -237,7 +218,6 @@
|
||||
"my files": "Meine Dateien",
|
||||
|
||||
"name": "Name",
|
||||
"'{name}' has been added to '{task}' by '{user}'.": "'{name}' wurde von {user} zu '{task}' hinzugefügt.",
|
||||
"net_price": "Nettopreis",
|
||||
"net_sum": "Netto-Summe",
|
||||
"new_contact": "neuer Kontakt",
|
||||
@@ -246,13 +226,11 @@
|
||||
"new_property": "neue Eigenschaft",
|
||||
"no_bookmark_for_urlid": "Kein Lesezeichen zur URL-ID {0}",
|
||||
"no_company": "keine Firma",
|
||||
"noon": "12:00 Uhr",
|
||||
"no_project_for_id": "Kein Projekt mit ID {0} gefunden!",
|
||||
"no_task_for_id": "Keine Aufgabe mit ID {0} gefunden!",
|
||||
"note": "Notiz",
|
||||
"note ({id})": "Notiz ({id})",
|
||||
"notes": "Notizen",
|
||||
"notification settings": "Benachrichtigungs-Einstellungen",
|
||||
"not_recent_version": "Die ist nicht die neuste Version dieser Seite!",
|
||||
"number": "Nummer",
|
||||
|
||||
@@ -286,7 +264,6 @@
|
||||
"processing_code": "Code wird verarbeitet…",
|
||||
"project": "Projekt",
|
||||
"project ({id})": "Projekt ({id})",
|
||||
"Project '{project}' was edited": "Projekt '{project}' wurde bearbeitet",
|
||||
"projects": "Projekte",
|
||||
"properties": "Eigenschaften",
|
||||
"property": "Eigenschaft",
|
||||
@@ -355,8 +332,6 @@
|
||||
"tags": "Tags",
|
||||
"task": "Aufgabe",
|
||||
"task_list": "Aufgabenliste",
|
||||
"'{task}' has been added to '{object}':\n\n{body}": "'{task}' wurde zu '{object}' hinzugefügt:\n\n{body}",
|
||||
"Task '{task}' was edited": "Aufgabe '{task}' wurde bearbeitet",
|
||||
"tasks": "Aufgaben",
|
||||
"tasks_for_tag": "Aufgaben mit Tag „{tag}“",
|
||||
"tax_id": "Steuernummer",
|
||||
@@ -364,19 +339,12 @@
|
||||
"tax_rate": "Steuersatz",
|
||||
"template": "Vorlage",
|
||||
"theme": "Design",
|
||||
"The project '{project}' has been created":"Das Projekt '{project}' wurde angelegt",
|
||||
"The project '{project}' has been deleted": "Das Projekt '{project}' wurde gelöscht",
|
||||
"The project '{project}' has been deleted by {user}": "Das Projekt '{project}' wurde von {user} gelöscht",
|
||||
"The task '{task}' has been created": "Die Aufgabe '{task}' wurde angelegt",
|
||||
"The task '{task}' has been deleted": "Die Aufgabe '{task}' wurde gelöscht",
|
||||
"The task '{task}' has been deleted by {user}": "Die Aufgabe '{task}' wurde von {user} gelöscht",
|
||||
"time ({id})": "Zeit ({id})",
|
||||
"times": "Zeiten",
|
||||
"timetracking": "Zeiterfassung",
|
||||
"title_not_available": "„{title}“ ist als Seitenname nicht mehr verfügbar!",
|
||||
"title_or_desc": "Titel/Beschreibung",
|
||||
"toggle_objects": "{objects} an/ausschalten",
|
||||
"To receive a new password, open the following link: {url}": "Um ein neues Passwort zu erhalten, öffnen Sie bitte den folgenden Link: {url}",
|
||||
"tutorial": "Tutorial",
|
||||
"type": "Dokumententyp",
|
||||
"type_confirmation": "Bestätigung",
|
||||
@@ -402,24 +370,20 @@
|
||||
"user_deleted_entity": "{user} hat \"{entity}\" gelöscht",
|
||||
"user_updated_entity": "{user} hat \"{entity}\" bearbeitet",
|
||||
|
||||
"value": "Wert",
|
||||
"version": "Version",
|
||||
"version_of": "Version {version} von {element}",
|
||||
"visible_to_guests": "Für Besucher sichtbar",
|
||||
|
||||
"website": "Website",
|
||||
"welcome" : "Willkommen, {0}",
|
||||
"When shall messages be delivered?": "Wann sollen Nachrichten zugestellt werden?",
|
||||
"wiki": "Wiki",
|
||||
"wikis": "Wiki-Seiten",
|
||||
"wiki page": "Wiki-Seite",
|
||||
"wiki pages": "Wiki-Seiten",
|
||||
"wiki_pages": "Wiki-Seiten",
|
||||
|
||||
"value": "Wert",
|
||||
"version": "Version",
|
||||
"version_of": "Version {version} von {element}",
|
||||
"visible_to_guests": "Für Besucher sichtbar",
|
||||
|
||||
"year": "Jahr",
|
||||
"You can view/edit this project at {base_url}/project/{id}/view": "Du kannst dieses Projekt unter {base_url}/project/{id}/view ansehen/bearbeiten.",
|
||||
"You can view/edit this task at {base_url}/task/{id}/view": "Du kannst diese Aufgabe unter {base_url}/task/{id}/view ansehen/bearbeiten.",
|
||||
"You have been added to the new project '{project}', created by {user}:\n\n{body}": "Du wurdest zum neuen Projekt '{project}', angelegt von {user}, hinzugefügt:\n\n{body}",
|
||||
"Your token to create a new password" : "Ihr Token zum Erstellen eines neuen Passworts",
|
||||
"your_password_reset_token" : "Ihr Token zum Erstellen eines neuen Passworts",
|
||||
"your_profile": "dein Profil"
|
||||
}
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
{
|
||||
"8:00 am": "8:00 am",
|
||||
"9:00 am": "9:00 am",
|
||||
"10:00 am": "10:00 am",
|
||||
"11:00 am": "11:00 am",
|
||||
"1:00 pm": "1:00 pm",
|
||||
"2:00 pm": "2:00 pm",
|
||||
"3:00 pm": "3:00 pm",
|
||||
"4:00 pm": "4:00 pm",
|
||||
"5:00 pm": "5:00 pm",
|
||||
"6:00 pm": "6:00 pm",
|
||||
"7:00 pm": "7:00 pm",
|
||||
"8:00 pm": "8:00 pm",
|
||||
"9:00 pm": "9:00 pm",
|
||||
"10:00 pm": "10:00 pm",
|
||||
|
||||
"abort": "abort",
|
||||
"actions": "actions",
|
||||
"add_login_service": "add login service",
|
||||
@@ -33,15 +18,12 @@
|
||||
"by": "by",
|
||||
|
||||
"cancel": "cancel",
|
||||
"Changes in project '{project}':\n\n{body}": "Changes in project '{project}':\n\n{body}",
|
||||
"Changes in task '{task}':\n\n{body}": "Changes in task '{task}':\n\n{body}",
|
||||
"choose_type": "choose type",
|
||||
"click_to_edit": "click to edit",
|
||||
"client_id": "client ID",
|
||||
"client_secret": "client secret",
|
||||
"close_settings": "close settings",
|
||||
"code": "code",
|
||||
"collect messages and send them at": "collect messages and send them at",
|
||||
"color": "color",
|
||||
"connect_service": "connect with service",
|
||||
"connected_services": "connected login services",
|
||||
@@ -98,8 +80,8 @@
|
||||
"do_login" : "do login",
|
||||
"do_open" : "open",
|
||||
"do_send" : "send",
|
||||
"drag_n_drop": "drag & drop",
|
||||
"due_date": "due date",
|
||||
"drag_n_drop": "drag & drop",
|
||||
"duration": "duration",
|
||||
|
||||
"easy_list": "Easy List",
|
||||
@@ -161,6 +143,7 @@
|
||||
|
||||
"given_name": "given name",
|
||||
"go": "go!",
|
||||
"go_to_url_to_reset_password": "To receive a new password, open the following link: {url}",
|
||||
"gross_sum": "gross sum",
|
||||
|
||||
"head": "header text",
|
||||
@@ -170,11 +153,9 @@
|
||||
"hours": "hours",
|
||||
|
||||
"id": "ID",
|
||||
"i don`t want to receive email notifications!": "i don`t want to receive email notifications!",
|
||||
"impersonate": "impersonate",
|
||||
"IMPERSONATE": "impersonate",
|
||||
"index_page": "task overview",
|
||||
"instantly": "instantly",
|
||||
"invert_filter": "Filter umkehren",
|
||||
"invoice": "invoice",
|
||||
"item": "Item",
|
||||
@@ -237,7 +218,6 @@
|
||||
"my files": "my files",
|
||||
|
||||
"name": "Name",
|
||||
"'{name}' has been added to '{object}' by '{user}'.": "'{name}' has been added to '{object}' by '{user}'.",
|
||||
"net_price": "net price",
|
||||
"net_sum": "net sum",
|
||||
"new_contact": "new contact",
|
||||
@@ -246,13 +226,11 @@
|
||||
"new_property": "new property",
|
||||
"no_bookmark_for_urlid": "No bookmark with urlId {0}",
|
||||
"no_company": "no company",
|
||||
"noon": "noon",
|
||||
"no_project_for_id": "No project found for id {0}",
|
||||
"no_task_for_id": "No task found for id {0}",
|
||||
"note": "note",
|
||||
"note ({id})":"note ({id})",
|
||||
"notes": "notes",
|
||||
"notification settings": "notification settings",
|
||||
"not_recent_version": "This is not the current version of this page!",
|
||||
"number": "number",
|
||||
|
||||
@@ -286,7 +264,6 @@
|
||||
"processing_code": "processing code…",
|
||||
"project": "project",
|
||||
"project ({id})": "project ({id})",
|
||||
"Project '{project}' was edited": "Project '{project}' was edited",
|
||||
"projects": "projects",
|
||||
"properties": "properties",
|
||||
"property": "property",
|
||||
@@ -355,8 +332,6 @@
|
||||
"tags": "tags",
|
||||
"task": "task",
|
||||
"task_list": "task list",
|
||||
"'{task}' has been added to '{object}':\n\n{body}": "'{task}' has been added to '{object}':\n\n{body}",
|
||||
"Task '{task}' was edited": "Task '{task}' was edited",
|
||||
"tasks": "tasks",
|
||||
"tasks_for_tag": "tasks with tag „{tag}“",
|
||||
"tax_id": "tax ID",
|
||||
@@ -364,19 +339,12 @@
|
||||
"tax_rate": "tax rate",
|
||||
"template": "template",
|
||||
"theme": "design",
|
||||
"The project '{project}' has been created":"The project '{project}' has been created",
|
||||
"The project '{project}' has been deleted": "The project '{project}' has been deleted",
|
||||
"The project '{project}' has been deleted by {user}": "The project '{project}' has been deleted by {user}",
|
||||
"The task '{task}' has been created": "The task '{task}' has been created",
|
||||
"The task '{task}' has been deleted": "The task '{task}' has been deleted",
|
||||
"The task '{task}' has been deleted by {user}": "The task '{task}' has been deleted by {user}",
|
||||
"time ({id})": "time ({id})",
|
||||
"times": "times",
|
||||
"timetracking": "time tracking",
|
||||
"title_not_available": "„{title}“ is not available as page name!",
|
||||
"title_or_desc": "title/description",
|
||||
"toggle_objects": "toggle {objects}",
|
||||
"To receive a new password, open the following link: {url}": "To receive a new password, open the following link: {url}",
|
||||
"tutorial": "tutorial",
|
||||
"type": "type",
|
||||
"type_confirmation": "confirmation",
|
||||
@@ -402,24 +370,20 @@
|
||||
"user_deleted_entity": "{user} deleted \"{entity}\"",
|
||||
"user_updated_entity": "{user} updated \"{entity}\"",
|
||||
|
||||
"value": "value",
|
||||
"version": "version",
|
||||
"version_of": "version {version} of {element}",
|
||||
"visible_to_guests": "visible to guests",
|
||||
|
||||
"website": "website",
|
||||
"welcome" : "Welcome, {0}",
|
||||
"When shall messages be delivered?": "When shall messages be delivered?",
|
||||
"wiki": "Wiki",
|
||||
"wikis": "wiki pages",
|
||||
"wiki page": "wiki page",
|
||||
"wiki pages": "wiki pages",
|
||||
"wiki_pages": "wiki pages",
|
||||
|
||||
"value": "value",
|
||||
"version": "version",
|
||||
"version_of": "version {version} of {element}",
|
||||
"visible_to_guests": "visible to guests",
|
||||
|
||||
"year": "year",
|
||||
"You can view/edit this project at {base_url}/project/{id}/view": "You can view/edit this project at {base_url}/project/{id}/view",
|
||||
"You can view/edit this task at {base_url}/task/{id}/view": "You can view/edit this task at {base_url}/task/{id}/view",
|
||||
"You have been added to the new project '{project}', created by {user}:\n\n{body}": "You have been added to the new project '{project}', created by {user}:\n\n{body}",
|
||||
"Your token to create a new password" : "Your token to create a new password",
|
||||
"your_password_reset_token" : "Your token to create a new password",
|
||||
"your_profile": "your profile"
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import static de.srsoftware.umbrella.core.constants.Field.STATE;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.USER;
|
||||
import static de.srsoftware.umbrella.core.constants.Path.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.user.Constants.*;
|
||||
import static de.srsoftware.umbrella.user.Paths.*;
|
||||
import static de.srsoftware.umbrella.user.Paths.IMPERSONATE;
|
||||
@@ -503,10 +502,11 @@ public class UserModule extends BaseHandler implements UserService {
|
||||
if (oldToken != null) tokenMap.remove(oldToken);
|
||||
tokenMap.put(token,email);
|
||||
tokenMap.put(email,token);
|
||||
var subject = "user.your_password_reset_token";
|
||||
var content = "user.go_to_url_to_reset_password";
|
||||
var url = url(ex).replace("/api/user/reset_pw","/user/reset/pw")+"?token="+token;
|
||||
var subject = t("Your token to create a new password");
|
||||
var content = t("To receive a new password, open the following link: {url}",URL,url);
|
||||
var message = new Message(user,subject,content,null);
|
||||
var fills = Map.of("url",url);
|
||||
var message = new Message(user,subject,content,fills,null);
|
||||
var envelope = new Envelope(message,user);
|
||||
postBox().send(envelope);
|
||||
} catch (UmbrellaException e){
|
||||
|
||||
@@ -9,5 +9,4 @@ tasks.processResources {
|
||||
from("../frontend/dist") {
|
||||
into("web")
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
}
|
||||
@@ -100,10 +100,6 @@ nav a.mark::before {
|
||||
content: " ";
|
||||
}
|
||||
|
||||
nav a.message::before {
|
||||
content: " ";
|
||||
}
|
||||
|
||||
nav a.note::before {
|
||||
content: " ";
|
||||
}
|
||||
@@ -137,7 +133,6 @@ nav a.contact,
|
||||
nav a.doc,
|
||||
nav a.file,
|
||||
nav a.mark,
|
||||
nav a.message,
|
||||
nav a.note,
|
||||
nav a.project,
|
||||
nav a.stock,
|
||||
@@ -323,13 +318,6 @@ textarea{
|
||||
max-height: unset;
|
||||
}
|
||||
|
||||
.message.settings label{
|
||||
display: block;
|
||||
}
|
||||
.message.settings td{
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.project th,
|
||||
.task th{
|
||||
text-align: right;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
description = "Umbrella : Wiki"
|
||||
|
||||
dependencies{
|
||||
implementation(project(":bus"))
|
||||
implementation(project(":core"))
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import static de.srsoftware.umbrella.core.constants.Path.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Permission.EDIT;
|
||||
import static de.srsoftware.umbrella.core.model.Permission.READ_ONLY;
|
||||
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static de.srsoftware.umbrella.wiki.Constants.*;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
@@ -20,7 +19,6 @@ import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.api.WikiService;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
import de.srsoftware.umbrella.messagebus.events.WikiEvent;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
@@ -191,13 +189,10 @@ public class WikiModule extends BaseHandler implements WikiService {
|
||||
private boolean patchPage(Path path, UmbrellaUser user, HttpExchange ex) throws IOException {
|
||||
var id = path.pop();
|
||||
var page = loadPage(id, null);
|
||||
var old = page.toMap();
|
||||
var member = page.members().get(user.id());
|
||||
if (member == null || member.permission() != EDIT) throw forbidden("You are not allowed to edit {0}!", ID,id);
|
||||
var json = json(ex);
|
||||
page = wikiDb.save(page.patch(json, userService()));
|
||||
messageBus().dispatch(new WikiEvent(user,page,old));
|
||||
return sendContent(ex,page);
|
||||
return sendContent(ex,wikiDb.save(page.patch(json, userService())));
|
||||
}
|
||||
|
||||
private boolean postNewPage(String title, UmbrellaUser user, HttpExchange ex) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user