ACS-895 - User email should not be necessary for joining a site (#387)

This behaviour has been inconsistent anyway: It failed and prevented the user from being added to the site if there was no email address. But it proceeded if the email could not be sent for other reasons, like an invalid server name or non existing account on that server.
This commit is contained in:
Stefan Kopf
2021-05-11 19:24:27 +02:00
committed by GitHub
parent ca2766d859
commit 0742c8efbd

View File

@@ -1997,17 +1997,29 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
private void sendInviteEmail(InviteSender inviteSender, List<String> invitePropNames, String inviteId, String emailTemplateXpath, String emailSubjectKey, Map<String, Object> executionVariables)
{
if (isSendEmails())
// Do nothing if emails disabled.
if (isSendEmails() == false)
{
return;
}
// send email to the invitee if possible - but don't fail the invitation if email cannot be sent
try
{
Map<String, String> properties = makePropertiesFromContextVariables(executionVariables, invitePropNames);
String packageRef = getPackageRef(executionVariables);
properties.put(InviteNominatedSender.WF_PACKAGE, packageRef);
properties.put(InviteNominatedSender.WF_INSTANCE_ID, inviteId);
inviteSender.sendMail(emailTemplateXpath, emailSubjectKey, properties);
}
catch (Exception e)
{
// Swallow exception
logger.error("unable to send invite email", e);
}
}