diff --git a/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email.ftl b/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email.ftl index 0c4345237c..942550a889 100644 --- a/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email.ftl +++ b/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email.ftl @@ -15,5 +15,5 @@ To minimize any disruption to your ORCID integration in the future, we would rec Warm Regards, ORCID Support Team https://support.orcid.org -<@emailMacros.msg "email.common.you_have_received_this_email" /> + <#include "email_footer.ftl"/> diff --git a/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email_html.ftl b/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email_html.ftl index 569cb86ebe..f7d4ebca59 100644 --- a/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email_html.ftl +++ b/orcid-core/src/main/resources/org/orcid/core/template/papi_rate_limit_email_html.ftl @@ -25,9 +25,6 @@

- <@emailMacros.msg "email.common.you_have_received_this_email" /> -

-

<#include "email_footer_html.ftl"/>

diff --git a/orcid-pub-web/src/main/java/org/orcid/api/filters/ApiRateLimitFilter.java b/orcid-pub-web/src/main/java/org/orcid/api/filters/ApiRateLimitFilter.java index daa982cae3..e2f9aae1dd 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/filters/ApiRateLimitFilter.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/filters/ApiRateLimitFilter.java @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.MessageSource; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; @@ -79,6 +80,9 @@ public class ApiRateLimitFilter extends OncePerRequestFilter { @Autowired private OrcidTokenStore orcidTokenStore; + + @Autowired + private MessageSource messageSource; @Value("${org.orcid.papi.rate.limit.anonymous.requests:10000}") private int anonymousRequestLimit; @@ -202,8 +206,10 @@ private void rateLimitClientRequest(String clientId, LocalDate today) { private Map createTemplateParams(String clientId, String clientName, String emailName, String orcidId) { Map templateParams = new HashMap(); + templateParams.put("messages", messageSource); + templateParams.put("messageArgs", new Object[0]); templateParams.put("clientId", clientId); - templateParams.put("clientId", clientName); + templateParams.put("clientName", clientName); templateParams.put("emailName", emailName); templateParams.put("locale", LocaleUtils.toLocale("en")); templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); @@ -218,9 +224,9 @@ private void sendEmail(String clientId, LocalDate requestDate) { String emailName = recordNameManager.deriveEmailFriendlyName(profile.getId()); Map templateParams = this.createTemplateParams(clientId, clientDetailsEntity.getClientName(), emailName, profile.getId()); // Generate body from template - String body = templateManager.processTemplate("bad_orgs_email.ftl", templateParams); + String body = templateManager.processTemplate("papi_rate_limit_email.ftl", templateParams); // Generate html from template - String html = templateManager.processTemplate("bad_orgs_email_html.ftl", templateParams); + String html = templateManager.processTemplate("papi_rate_limit_email_html.ftl", templateParams); String email = emailManager.findPrimaryEmail(profile.getId()).getEmail(); LOG.info("text email={}", body); diff --git a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java index 898a1896c8..73b1b4258c 100644 --- a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java +++ b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java @@ -71,8 +71,8 @@ public void papiDailyLimitReport() { if (enableRateLimiting) { LocalDate yesterday = LocalDate.now().minusDays(1); String mode = Features.ENABLE_PAPI_RATE_LIMITING.isActive() ? "ENFORCEMENT" : "MONITORING"; - String SLACK_INTRO_MSG = "Public API Rate limit report - Date: " + yesterday.toString() + "\n Current Anonymous Requests Limit: " + anonymousRequestLimit - + "\nCurrent Public API Clients Limit: " + knownRequestLimit + "\n Mode: " + mode; + String SLACK_INTRO_MSG = "Public API Rate limit report - Date: " + yesterday.toString() + "\nCurrent Anonymous Requests Limit: " + anonymousRequestLimit + + "\nCurrent Public API Clients Limit: " + knownRequestLimit + "\nMode: " + mode; LOG .info(SLACK_INTRO_MSG); slackManager.sendAlert(SLACK_INTRO_MSG, slackChannel, webhookUrl, webhookUrl);