Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extract specific recipient email value from flow file attributes #52

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public PasswordAuthentication getPasswordAuthentication() {
*/
private InternetAddress[] toInetAddresses(final ReportingContext context, PropertyDescriptor propertyDescriptor)
throws AddressException {
InternetAddress[] parse = new InternetAddress[0];
InternetAddress[] parse;
final String value = context.getProperty(propertyDescriptor).getValue();

if (value == null || value.isEmpty()) {
Expand Down Expand Up @@ -278,7 +278,8 @@ private Charset getCharset(final ReportingContext context) {

private String getSpecificRecipientValue(final ReportingContext context, final Map<String, Object> event) {
final String specificRecipientAttributeName = context.getProperty(SPECIFIC_RECIPIENT_ATTRIBUTE_NAME).getValue();
return (String) event.get(specificRecipientAttributeName);
Map<String, String> eventPreviousAttributes = (Map<String, String>) event.get("previous_attributes");
return eventPreviousAttributes.get(specificRecipientAttributeName);
}

private String composeMessageContent(final Map<String, Object> event) {
Expand Down Expand Up @@ -349,7 +350,10 @@ public void sendErrorEmail(Map<String, Object> event, ReportingContext context)
final Session mailSession = this.createMailSession(properties, context);
final Message message = new MimeMessage(mailSession);
InternetAddress[] inetAddressesArray;
String specificRecipientAttributeValue = getSpecificRecipientValue(context, event);
String specificRecipientAttributeValue = null;
if (event.containsKey("previous_attributes") && context.getProperty(SPECIFIC_RECIPIENT_ATTRIBUTE_NAME).getValue() != null) {
specificRecipientAttributeValue = getSpecificRecipientValue(context, event);
}

if (specificRecipientAttributeValue != null) {
inetAddressesArray = (InternetAddress[]) Stream.of(
Expand Down
Loading