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

ufal/be-fix-email-parameters #470

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
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 @@ -84,12 +84,17 @@ public ResponseEntity sendEmail(HttpServletRequest request, HttpServletResponse
return null;
}

// Fetch DSpace main cfg info and send it in the email
String uiUrl = configurationService.getProperty("dspace.ui.url");
String helpDeskEmail = configurationService.getProperty("lr.help.mail", "");
String helpDeskPhoneNum = configurationService.getProperty("lr.help.phone", "");
String dspaceName = configurationService.getProperty("dspace.name", "");
String dspaceNameShort = configurationService.getProperty("dspace.name.short", "");

if (StringUtils.isEmpty(uiUrl)) {
log.error("Cannot load the `dspace.ui.url` property from the cfg.");
throw new RuntimeException("Cannot load the `dspace.ui.url` property from the cfg.");
}

// Generate token and create ClarinVerificationToken record with the token and user email.
String verificationToken = Utils.generateHexKey();
clarinVerificationToken.setEmail(email);
Expand All @@ -103,6 +108,11 @@ public ResponseEntity sendEmail(HttpServletRequest request, HttpServletResponse
Locale locale = context.getCurrentLocale();
Email bean = Email.getEmail(I18nUtil.getEmailFilename(locale, "clarin_autoregistration"));
bean.addArgument(autoregistrationURL);
bean.addArgument(helpDeskEmail);
bean.addArgument(helpDeskPhoneNum);
bean.addArgument(dspaceNameShort);
bean.addArgument(dspaceName);
bean.addArgument(uiUrl);
bean.addRecipient(email);
bean.send();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,18 @@ private void sendEmailWithDownloadLink(Context context, UUID bitstreamUUID,
throw new BadRequestException("Cannot find the clarin license for the bitstream with ID: " + bitstreamUUID);
}

// Fetch DSpace main cfg info and send it in the email
String uiUrl = configurationService.getProperty("dspace.ui.url", "");
String helpDeskEmail = configurationService.getProperty("lr.help.mail", "");
String helpDeskPhoneNum = configurationService.getProperty("lr.help.phone", "");
String dspaceName = configurationService.getProperty("dspace.name", "");
String dspaceNameShort = configurationService.getProperty("dspace.name.short", "");

if (StringUtils.isEmpty(uiUrl)) {
log.error("Cannot load the `dspace.ui.url` property from the cfg.");
throw new RuntimeException("Cannot load the `dspace.ui.url` property from the cfg.");
}
// Compose download link
// Get UI url
String uiUrl = configurationService.getProperty("dspace.ui.url");
String downloadLink = uiUrl + "/" + BitstreamRest.PLURAL_NAME + "/" + bitstream.getID() + "/download?dtoken=" +
downloadToken;

Expand All @@ -185,6 +194,11 @@ private void sendEmailWithDownloadLink(Context context, UUID bitstreamUUID,
bean.addArgument(bitstream.getName());
bean.addArgument(downloadLink);
bean.addArgument(clarinLicense.getDefinition());
bean.addArgument(helpDeskEmail);
bean.addArgument(helpDeskPhoneNum);
bean.addArgument(dspaceNameShort);
bean.addArgument(dspaceName);
bean.addArgument(uiUrl);
bean.addRecipient(email);
bean.send();
} catch (MessagingException e) {
Expand Down
6 changes: 6 additions & 0 deletions dspace/config/clarin-dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# one day similar to this
# https://github.com/ufal/clarin-dspace/blob/clarin/utilities/project_helpers/config/local.conf.dist

#------------------------------------------------------------------#
#---------------------------DSpace---------------------------------#
#------------------------------------------------------------------#
dspace.name.short = DSpace
dspace.name = CLARIN DSpace

#------------------------------------------------------------------#
#---------------------------UPLOAD FILE----------------------------#
#------------------------------------------------------------------#
Expand Down
35 changes: 24 additions & 11 deletions dspace/config/emails/clarin_autoregistration
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
## E-mail sent to confirm authenticity of the user's e-mail.
##
## Parameters: {0} confirmation e-mail
##
## See org.dspace.core.Email for information on the format of this file.
##
# E-mail sent to confirm authenticity of the user's e-mail.
#
# Parameters: {0} confirmation e-mail
# {1} helpdesk email
# {2} helpdesk phone number
# {3} DSpace name short
# {4} DSpace name
# {5} DSpace UI url
#
# See org.dspace.core.Email for information on the format of this file.
#
Subject: ${params[3]}: Account Registration
To complete registration for a ${params[3]} repository account at {params[5]}, please click the link below:

Confirmation e-mail: ${params[0]}
${params[0]}

If you need assistance with your account, please email
${params[1]} or call us at ${params[2]}


${params[3]} Team

_____________________________________
${dspace.name},
WWW: ${dspace.url}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot use this notion anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Email: ${lr.help.mail}
Tel.: ${lr.help.phone}
${params[4]},
WWW: ${params[5]}
Email: ${params[1]}
Tel.: ${params[2]}
23 changes: 14 additions & 9 deletions dspace/config/emails/clarin_download_link
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@
# Parameters: {0} is expanded to filename
# {1} to a download URL
# {2} to license url
# {3} helpdesk email
# {4} helpdesk phone number
# {5} DSpace name short
# {6} DSpace name
# {7} DSpace UI url
#
# See org.dspace.core.Email for information on the format of this file.
#
Subject: ${lr.dspace.name.short}: Download instructions for {0}
Subject: ${params[5]}: Download instructions for ${params[0]}
To download the file you have requested, please click the link below:
{1}
${params[1]}

Remember, the file is distributed under specific license:
{2}
${params[2]}

If you have trouble downloading the file or if you did not request this download please contact
${lr.help.mail} or call us at ${lr.help.phone}
${params[3]} or call us at ${params[4]}


${lr.dspace.name.short} Team
${params[5]} Team

_____________________________________
${dspace.name},
WWW: ${dspace.url}
Email: ${lr.help.mail}
Tel.: ${lr.help.phone}
${params[6]},
WWW: ${params[7]}
Email: ${params[3]}
Tel.: ${params[4]}
Loading