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

Metadata publication notifications / allow to configure the mail format #8497

Merged
Show file tree
Hide file tree
Changes from 2 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
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 are sent as `text/html` messages, this can be changed using ```WEB-INF/config.properties``` configuration:
jodygarnett marked this conversation as resolved.
Show resolved Hide resolved

```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: 2 additions & 1 deletion web/src/main/webResources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ analytics.web.jscode=
#analytics.web.service=matomo
#analytics.web.jscode=var _paq = _paq || [];_paq.push(['trackPageView']);_paq.push(['enableLinkTracking']);(function() {var u="//localhost/";_paq.push(['setTrackerUrl', u+'piwik.php']);_paq.push(['setSiteId', '1']);var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);})();var currentUrl = location.href; window.addEventListener('hashchange', function() {_paq.push(['setReferrerUrl', currentUrl]);currentUrl = window.location.href;_paq.push(['setCustomUrl', currentUrl]);_paq.push(['setDocumentTitle', currentUrl]);_paq.push(['deleteCustomVariables', 'page']);_paq.push(['trackPageView']);var content = document.getElementsByTagName('body')[0];_paq.push(['MediaAnalytics::scanForMedia', content]);_paq.push(['FormAnalytics::scanForForms', content]);_paq.push(['trackContentImpressionsWithinNode', content]);_paq.push(['enableLinkTracking']);});


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