Skip to content

Commit

Permalink
Metadata publication notifications / allow to configure the mail form…
Browse files Browse the repository at this point in the history
…at (#8497)

* Metadata publication notifications / allow to configure the mail format: html / text
* document multi-lingual email configuration, and metadata.publicationmail.format.html option.

Co-authored-by: Jose García <[email protected]>

---------

Co-authored-by: Jody Garnett <[email protected]>
  • Loading branch information
josegar74 and jodygarnett committed Nov 15, 2024
1 parent 8890615 commit 5ac3f96
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,41 @@ JVM proxy parameters may also be required to properly set the proxy for all remo

## Feedback {#system-config-feedback}

Email may be sent by the catalog.
Email notifications are sent by the catalog.

- you are using the User Self-registration system
- you are using the metadata status workflow (See [Life cycle](../../user-guide/workflow/life-cycle.md))
- a file uploaded with a metadata record is downloaded and notify privilege is selected
- When using the User Self-registration system.
- When using the metadata status workflow (See [Life cycle](../../user-guide/workflow/life-cycle.md)).
- When a file uploaded with a metadata record is downloaded and notify privilege is selected.

This section configure the mail server to use.

- **Email** This is the administrator's email address used to send feedback.
- **SMTP host** The mail server name or IP address to use for sending emails.
- **SMTP port** The SMTP port.
- **Use SSL** Enable SSL mode
- **Use SSL** Enable Secure Sockets Layer (SSL) mode
- **User name** Username if connection is required on the SMTP server
- **Password** Username password if connection is required on the SMTP server
- **Use TLS** Enable use of Transport Layer Security (TLS)

![](img/feedback-email.png)

Additional settings are available to respect user language preference:

- **Language for system generated emails** The ui language will be used when sending notification emails by default. To To override this behaviour and generate a multi-lingual notification email list the langauges to be used.

- **Translation follows text** Provide an introduction phrase indicating a multi-lingual notification follows.

![](img/feedback-multilingual.png)

!!! note

Email notifications for metadata publication are sent as `text/html` messages, this can be changed using ```WEB-INF/config.properties``` configuration:

```properties
# Configure the metadata publication notification mails to be sent as HTML (true) or TEXT (false)
metadata.publicationmail.format.html=true
```

## Metadata search results

Configuration settings in this group determine what the limits are on user interaction with the search results.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2023 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down Expand Up @@ -34,6 +34,7 @@
import org.fao.geonet.repository.GroupRepository;
import org.fao.geonet.utils.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.*;
Expand All @@ -48,6 +49,9 @@

@Component
public class MetadataPublicationMailNotifier {
@Value("${metadata.publicationmail.format.html:true}")
private boolean sendHtmlMail;

@Autowired
SettingManager settingManager;

Expand Down Expand Up @@ -136,7 +140,6 @@ private void sendMailPublicationNotification(Locale[] feedbackLocales,
LocalizedEmailComponent emailMessageComponent = new LocalizedEmailComponent(MESSAGE, "metadata_published_text", KeyType.MESSAGE_KEY, POSITIONAL_FORMAT);

for (Locale feedbackLocale : feedbackLocales) {

emailSubjectComponent.addParameters(
feedbackLocale,
new LocalizedEmailParameter(ParameterType.RAW_VALUE, 1, settingManager.getSiteName())
Expand Down Expand Up @@ -175,15 +178,19 @@ private void sendMailPublicationNotification(Locale[] feedbackLocales,
);
}

LocalizedEmail localizedEmail = new LocalizedEmail(true);
LocalizedEmail localizedEmail = new LocalizedEmail(sendHtmlMail);
localizedEmail.addComponents(emailSubjectComponent, emailMessageComponent);

String subject = localizedEmail.getParsedSubject(feedbackLocales);
String htmlMessage = localizedEmail.getParsedMessage(feedbackLocales);
String message = localizedEmail.getParsedMessage(feedbackLocales);

// Send mail to notify about metadata publication / un-publication
try {
MailUtil.sendHtmlMail(toAddress, subject, htmlMessage, settingManager);
if (sendHtmlMail) {
MailUtil.sendHtmlMail(toAddress, subject, message, settingManager);
} else {
MailUtil.sendMail(toAddress, subject, message, settingManager);
}
} catch (IllegalArgumentException ex) {
Log.warning(API.LOG_MODULE_NAME, ex.getMessage(), ex);
}
Expand Down
3 changes: 3 additions & 0 deletions web/src/main/webResources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ map.bbox.background.service=https://ows.terrestris.de/osm/service?SERVICE=WMS&am
metadata.extentApi.disableFullUrlBackgroundMapServices=true

db.migration_onstartup=true

# Configure the metadata publication notification mails to be sent as HTML (true) or TEXT (false)
metadata.publicationmail.format.html=true

0 comments on commit 5ac3f96

Please sign in to comment.