#119 add leader changed notification
This commit is contained in:
parent
4262446aef
commit
74a8dcbd8a
@ -18,10 +18,12 @@ public class GrantNotificationService {
|
|||||||
private final static String TEMPLATE_DEADLINE = "grantDeadlineNotification";
|
private final static String TEMPLATE_DEADLINE = "grantDeadlineNotification";
|
||||||
private final static String TEMPLATE_CREATE = "grantCreateNotification";
|
private final static String TEMPLATE_CREATE = "grantCreateNotification";
|
||||||
private final static String TEMPLATE_AUTHORS_CHANGED = "grantAuthorsChangeNotification";
|
private final static String TEMPLATE_AUTHORS_CHANGED = "grantAuthorsChangeNotification";
|
||||||
|
private final static String TEMPLATE_LEADER_CHANGED = "grantLeaderChangeNotification";
|
||||||
|
|
||||||
private final static String TITLE_DEADLINE = "Приближается дедлайн гранта: %s";
|
private final static String TITLE_DEADLINE = "Приближается дедлайн гранта: %s";
|
||||||
private final static String TITLE_CREATE = "Создан грант: %s";
|
private final static String TITLE_CREATE = "Создан грант: %s";
|
||||||
private final static String TITLE_AUTHORS_CHANGED = "Изменился состав рабочей группы гранта: %s";
|
private final static String TITLE_AUTHORS_CHANGED = "Изменился состав рабочей группы гранта: %s";
|
||||||
|
private final static String TITLE_LEADER_CHANGED = "Изменился руководитель гранта: %s";
|
||||||
|
|
||||||
private final MailService mailService;
|
private final MailService mailService;
|
||||||
|
|
||||||
@ -53,14 +55,18 @@ public class GrantNotificationService {
|
|||||||
sendForAllAuthors(variables, grant, TEMPLATE_CREATE, String.format(TITLE_CREATE, grant.getTitle()));
|
sendForAllAuthors(variables, grant, TEMPLATE_CREATE, String.format(TITLE_CREATE, grant.getTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void authorsChangeNotification(Grant grant, List<User> oldAuthors) {
|
public void sendAuthorsChangeNotification(Grant grant, Set<User> oldAuthors) {
|
||||||
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldAuthors", oldAuthors);
|
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldAuthors", oldAuthors);
|
||||||
sendForAllAuthors(variables, grant, TEMPLATE_AUTHORS_CHANGED, String.format(TITLE_AUTHORS_CHANGED, grant.getTitle()));
|
sendForAllAuthors(variables, grant, TEMPLATE_AUTHORS_CHANGED, String.format(TITLE_AUTHORS_CHANGED, grant.getTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendLeaderChangeNotification(Grant grant, User oldLeader) {
|
||||||
|
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldLeader", oldLeader);
|
||||||
|
sendForAllAuthors(variables, grant, TEMPLATE_LEADER_CHANGED, String.format(TITLE_LEADER_CHANGED, grant.getTitle()));
|
||||||
|
}
|
||||||
private void sendForAllAuthors(Map<String, Object> variables, Grant grant, String template, String title) {
|
private void sendForAllAuthors(Map<String, Object> variables, Grant grant, String template, String title) {
|
||||||
Set<User> allAuthors = grant.getAuthors();
|
Set<User> allAuthors = grant.getAuthors();
|
||||||
allAuthors.add(grant.getLeader());
|
|
||||||
allAuthors.forEach(author -> mailService.sendEmailFromTemplate(variables, author, template, title));
|
allAuthors.forEach(author -> mailService.sendEmailFromTemplate(variables, author, template, title));
|
||||||
|
mailService.sendEmailFromTemplate(variables, grant.getLeader(), template, title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user