Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
fix(email): bad templates
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGeraud authored and brasseld committed Aug 18, 2017
1 parent d40fb3f commit 7bbea2e
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public class MembershipServiceImpl extends TransactionalService implements Membe
@Autowired
private RoleService roleService;

@Autowired
private ApplicationService applicationService;

@Autowired
private ApiService apiService;

@Autowired
private GroupService groupService;

@Override
public Set<MemberEntity> getMembers(MembershipReferenceType referenceType, String referenceId) {
return getMembers(referenceType, referenceId, null, null);
Expand Down Expand Up @@ -247,27 +256,31 @@ private EmailNotification buildEmailNotification(UserEntity user, MembershipRefe
String subject = null;
EmailNotificationBuilder.EmailTemplate template = null;
Map params = null;

GroupEntity groupEntity;
switch (referenceType) {
case APPLICATION:
subject = "Subscription to application " + referenceId;
ApplicationEntity applicationEntity = applicationService.findById(referenceId);
subject = "Subscription to application " + applicationEntity.getName();
template = EmailNotificationBuilder.EmailTemplate.APPLICATION_MEMBER_SUBSCRIPTION;
params = ImmutableMap.of("application", referenceId, "username", user.getUsername());
params = ImmutableMap.of("application", applicationEntity, "username", user.getUsername());
break;
case API:
subject = "Subscription to API " + referenceId;
ApiEntity apiEntity = apiService.findById(referenceId);
subject = "Subscription to API " + apiEntity.getName();
template = EmailNotificationBuilder.EmailTemplate.API_MEMBER_SUBSCRIPTION;
params = ImmutableMap.of("api", referenceId, "username", user.getUsername());
params = ImmutableMap.of("api", apiEntity, "username", user.getUsername());
break;
case APPLICATION_GROUP:
subject = "Subscription to application group " + referenceId;
groupEntity = groupService.findById(referenceId);
subject = "Subscription to application group " + groupEntity.getName();
template = EmailNotificationBuilder.EmailTemplate.APPLICATION_GROUP_MEMBER_SUBSCRIPTION;
params = ImmutableMap.of("group", referenceId, "username", user.getUsername());
params = ImmutableMap.of("group", groupEntity, "username", user.getUsername());
break;
case API_GROUP:
subject = "Subscription to API group " + referenceId;
groupEntity = groupService.findById(referenceId);
subject = "Subscription to API group " + groupEntity.getName();
template = EmailNotificationBuilder.EmailTemplate.API_MEMBER_GROUP_SUBSCRIPTION;
params = ImmutableMap.of("group", referenceId, "username", user.getUsername());
params = ImmutableMap.of("group", groupEntity, "username", user.getUsername());
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ public SubscriptionEntity create(String plan, String application) {
.params(ImmutableMap.of(
"owner", appOwner,
"api", api,
"plan", plan,
"application", application))
"plan", planEntity,
"application", applicationEntity))
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${username},</h3>
<p>You are now a member of the group of APIs: ${group}</p>
<p>You are now a member of the group of APIs: ${group.name}</p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<#include "header.html" />
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${owner},</h3>
<h3>Hi ${owner.username},</h3>
<p>The API Key <code>${apiKey}</code> has been expired.
</p>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<#include "header.html" />
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${owner},</h3>
<h3>Hi ${owner.username},</h3>
<p>The API Key <code>${apiKey}</code> has been revoked</p>
</div>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${username},</h3>
<p>You are now a member of the API: ${api}</p>
<p>You are now a member of the API: ${api.name}</p>
</div>

</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${username},</h3>
<p>You are now a member of the group of Applications: ${group}</p>
<p>You are now a member of the group of Applications: ${group.name}</p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${username},</h3>
<p>You are now a member of the application: ${application}</p>
<p>You are now a member of the application: ${application.name}</p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<#include "header.html" />
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${owner},</h3>
<p>Your subscription to the API <code>${api}</code> with plan <code>${plan}</code> has been approved.</p>
<h3>Hi ${owner.username},</h3>
<p>Your subscription to the API <code>${api.name}</code> with plan <code>${plan.name}</code> has been approved.</p>
</div>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<#include "header.html" />
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${owner},</h3>
<p><code>${application}</code> has just subscribed to the API <code>${api}</code> with plan <code>${plan}</code>.</p>
<h3>Hi ${owner.username},</h3>
<p><code>${application.name}</code> has just subscribed to the API <code>${api.name}</code> with plan <code>${plan.name}</code>.</p>
</div>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<#include "header.html" />
</header>
<div style="margin-top: 50px; color: #424e5a;">
<h3>Hi ${owner},</h3>
<p>Your subscription to the API <code>${api}</code> with plan <code>${plan}</code> has been rejected.</p>
<h3>Hi ${owner.username},</h3>
<p>Your subscription to the API <code>${api.name}</code> with plan <code>${plan.name}</code> has been rejected.</p>
</div>
</body>
</html>
</html>

0 comments on commit 7bbea2e

Please sign in to comment.