Skip to content

Commit

Permalink
Change invitation emails for group admins
Browse files Browse the repository at this point in the history
  • Loading branch information
cgeorgilakis-grnet committed Nov 15, 2024
1 parent 22710a6 commit 6e55ffe
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Change suspend and reactivate email
- Change group membership update email
- Change invitation emails for group admins

### Fixed
- General email fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,19 +287,21 @@ public void sendRejectionInvitationEmail(UserModel userModel, String groupPath,
send("groupRejectionInvitationSubject", Stream.of(titleType, groupPath).collect(Collectors.toList()), "reject-invitation.ftl", attributes);
}

public void sendInvitionAdminInformationEmail(String email, boolean forMember, String groupname, UserModel admin, List<String> groupRoles) throws EmailException {
public void sendInvitionAdminInformationEmail(String email, boolean forMember, String groupPath, UserModel admin, List<String> groupRoles) throws EmailException {
attributes.put("fullname", user.getFirstName() + " " + user.getLastName());
attributes.put("email", email);
attributes.put("type", forMember ? "member" : "admin");
attributes.put("type", forMember ? "a member" : "an administrator");
if (forMember && groupRoles != null && !groupRoles.isEmpty()) {
StringBuilder sb2 = new StringBuilder(groupname).append(" with roles : ");
StringBuilder sb2 = new StringBuilder(groupPath).append(" with roles: ");
groupRoles.stream().forEach(role -> sb2.append(role).append(", "));
groupname = StringUtils.removeEnd(sb2.toString(), ", ");
String groupPathEnchance = StringUtils.removeEnd(sb2.toString(), ", ");
attributes.put("groupPath", groupPathEnchance);
} else {
attributes.put("groupPath", groupPath);
}
attributes.put("groupname", groupname);
attributes.put("adminFullName", admin.getFirstName() + " " + admin.getLastName());
attributes.put("signatureMessage", signatureMessage);
send(forMember ? "groupInvitationSubject" : "groupInvitationAdminInformSubject", "invitation-admin-inform.ftl", attributes);
send(forMember ? "groupInvitationSubject" : "groupInvitationAdminInformSubject", Stream.of(groupPath).collect(Collectors.toList()), "invitation-admin-inform.ftl", attributes);
}

public void sendAddRemoveAdminAdminInformationEmail(boolean added, String groupPath, String groupId, UserModel adminAdded, UserModel adminAction) throws EmailException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public Response inviteGroupAdmin(UserRepresentation userRep) throws EmailExcepti
groupAdminRepository.getAllAdminIdsGroupUsers(group).filter(x -> !groupAdmin.getId().equals(x)).map(id -> session.users().getUserById(realm, id)).forEach(admin -> {
try {
customFreeMarkerEmailTemplateProvider.setUser(admin);
customFreeMarkerEmailTemplateProvider.sendInvitionAdminInformationEmail(userRep.getEmail(), false, group.getName(), groupAdmin, null);
customFreeMarkerEmailTemplateProvider.sendInvitionAdminInformationEmail(userRep.getEmail(), false, org.rciam.plugins.groups.helpers.ModelToRepresentation.buildGroupPath(group), groupAdmin, null);
} catch (EmailException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Response inviteUser(GroupInvitationInitialRepresentation groupInvitationI
groupAdminRepository.getAllAdminIdsGroupUsers(group).filter(x -> !groupAdmin.getId().equals(x)).map(id -> session.users().getUserById(realm, id)).forEach(admin -> {
try {
customFreeMarkerEmailTemplateProvider.setUser(admin);
customFreeMarkerEmailTemplateProvider.sendInvitionAdminInformationEmail(user.getEmail(), true, group.getName(), groupAdmin, groupInvitationInitialRep.getGroupRoles());
customFreeMarkerEmailTemplateProvider.sendInvitionAdminInformationEmail(user.getEmail(), true, ModelToRepresentation.buildGroupPath(group), groupAdmin, groupInvitationInitialRep.getGroupRoles());
} catch (EmailException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<body>
${kcSanitize(msg("groupInvitationAdminInformBodyHtml", fullname, email, type, groupname, adminFullName, signatureMessage))?no_esc}
${kcSanitize(msg("groupInvitationAdminInformBodyHtml", fullname, adminFullName, email, type, groupPath, signatureMessage))?no_esc}
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ groupadminEnrollmentRequestCreationSubject= New enrollment request for {0} group
groupInvitationBody=You have been invited by {0} to join the {1} group.\n{2}\n{3}\nThe group path is {4}\nPlease follow the following link: {5}\n\nPlease note that this invitation will {6}.\n\nThank you,\n{7}
groupInvitationBodyHtml=<p>You have been invited by <strong>{0}</strong> to join the <strong>{1}</strong> group.</p><h4>{2}</h4><p>{3}<br><br>The group path is <strong>{4}</strong></p><a href="{5}" style="border-radius: 4px;color: white;background-color: #0077c8;text-decoration: none;display: inline-block;margin: 0;cursor:pointer;padding: 10px 10px;font-size: 20px;max-width: 150px;max-height: 30px">Join this group</a><p>You can also click the following link: <a href="{6}">{7}</a> </p><p>Please note that this invitation will {8}.</p><p>Thank you,<br>{9}</p>
groupInvitationSubject= Invitation to join group {0}
groupInvitationAdminInformBody=Dear {0},\n\n User with email {1} has been invited to become {2} of the group {3} by {4} group admin.\n\nThank you,\n{5}
groupInvitationAdminInformBodyHtml=<p>Dear {0},</p><p> User with email {1} has been invited to become {2} of the group {3} by {4} group admin.</p><p>Thank you,<br>{5}</p>
groupInvitationAdminInformSubject= Group admin invitation
groupInvitationAdminInformBody=Dear {0},\n\n User with email {1} has been invited by {2} to become {3} of the group {4}.\n\nThank you,\n{5}
groupInvitationAdminInformBodyHtml=<p>Dear {0},</p><p> User with email {1} has been invited by {2} to become {3} of the group {4}.</p><p>Thank you,<br>{5}</p>
groupInvitationAdminInformSubject= Administrator invitation for group {0}
groupAcceptInvitationBody=Dear {0},\n\n {1} with email {2} has accepted an invitation to {3} the {4}.\n\nFor more information about the group, please visit the following link: \n{5}\n\nThank you,\n{6}
groupAcceptInvitationBodyHtml=<p>Dear {0},</p><p>{1} with email {2} has accepted an invitation to {3} the {4}</p><p>For more information about the group, please visit the following link: <br>{5}</p><p>Thank you,<br>{6}</p>
groupRejectionInvitationBody=Dear {0},\n\n {1} with email {2} has rejected an invitation to {3} the {4}.\n\nFor more information about the group, please visit the following link:\n {5}\n\nThank you,\n{6}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<#ftl output_format="plainText">
${msg("groupInvitationAdminInformBody",fullname, email, type, groupname, adminFullName, signatureMessage)}
${msg("groupInvitationAdminInformBody",fullname, email, adminFullName, type, groupPath, signatureMessage)}

0 comments on commit 6e55ffe

Please sign in to comment.