From 0742c8efbdba3777c1d1340f3ed04cbc661287c2 Mon Sep 17 00:00:00 2001 From: Stefan Kopf Date: Tue, 11 May 2021 19:24:27 +0200 Subject: [PATCH] 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. --- .../repo/invitation/InvitationServiceImpl.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/repository/src/main/java/org/alfresco/repo/invitation/InvitationServiceImpl.java b/repository/src/main/java/org/alfresco/repo/invitation/InvitationServiceImpl.java index ea9aeb9a51..524461d524 100644 --- a/repository/src/main/java/org/alfresco/repo/invitation/InvitationServiceImpl.java +++ b/repository/src/main/java/org/alfresco/repo/invitation/InvitationServiceImpl.java @@ -1997,17 +1997,29 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli private void sendInviteEmail(InviteSender inviteSender, List invitePropNames, String inviteId, String emailTemplateXpath, String emailSubjectKey, Map 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 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); + } }