Skip to content

Commit

Permalink
Added: Email Context
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Nov 27, 2024
1 parent 7ffb06d commit 4a7890f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.0.1 - 2024-11-18]
## [0.0.1 - 2024-11-27]
### Added
- First version of the project
- Spring Application
Expand Down Expand Up @@ -158,3 +158,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Action explanations
- Integration of action explanatios in fetch Actions
- Action explanations templates
- Email Context
1 change: 1 addition & 0 deletions src/main/java/de/samply/app/ProjectManagerConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public class ProjectManagerConst {
public final static String FRONTEND_CONFIG = "frontend";
public final static String HTTP_PROXY_PREFIX = "http.proxy";
public final static String HTTPS_PROXY_PREFIX = "https.proxy";
public final static String EMAIL_CONTEXT = "email";

// Exporter
public final static String SECURITY_ENABLED = "SECURITY_ENABLED";
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/de/samply/email/EmailContext.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
package de.samply.email;

import lombok.Getter;
import de.samply.app.ProjectManagerConst;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
@ConfigurationProperties(prefix = ProjectManagerConst.EMAIL_CONTEXT)
@Data
public class EmailContext {

@Getter
private Map<String, String> keyValues = new HashMap<>();
private Map<String, String> context = new HashMap<>();


@PostConstruct
public void init() {
log.info("Email Context initialized:");
context.entrySet().stream().forEach(keyValue -> log.info("\t-\t{}: {}", keyValue.getKey(), keyValue.getValue()));
}

}
2 changes: 1 addition & 1 deletion src/main/java/de/samply/email/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void sendEmail(@NotNull String email, Optional<String> project, Optional<
});
bridgehead.ifPresent(b -> context.put(ProjectManagerConst.EMAIL_CONTEXT_BRIDGEHEAD, b));
context.putAll(keyValues);
context.putAll(emailContext.getKeyValues());
context.putAll(emailContext.getContext());
Optional<MessageSubject> messageSubject = createEmailMessageAndSubject(role, type, context);
if (messageSubject.isPresent()) {
sendEmail(email, messageSubject.get());
Expand Down

0 comments on commit 4a7890f

Please sign in to comment.