use of edu.stanford.bmir.protege.web.server.user.UserDetailsManager in project webprotege by protegeproject.
the class WatchTriggeredHandlerImpl method handleWatchTriggered.
@Override
public void handleWatchTriggered(@Nonnull Set<UserId> usersToNotify, @Nonnull OWLEntity modifiedEntity, @Nonnull UserId byUser) {
List<String> emailAddresses = usersToNotify.stream().filter(u -> accessManager.hasPermission(forUser(u), forProject(projectId), VIEW_PROJECT)).map(userDetailsManager::getEmail).filter(Optional::isPresent).map(Optional::get).distinct().collect(toList());
OWLEntityData modifiedEntityData = renderingManager.getRendering(modifiedEntity);
Map<String, Object> templateObjects = TemplateObjectsBuilder.builder().withUserId(byUser).withEntity(modifiedEntityData).withProjectDetails(projectDetailsManager.getProjectDetails(projectId)).withApplicationName(applicationNameSupplier.get()).withProjectUrl(placeUrl.getProjectUrl(projectId)).build();
String displayName = projectDetailsManager.getProjectDetails(projectId).getDisplayName();
String emailSubject = String.format("[%s] Changes made to %s in %s by %s", displayName, modifiedEntityData.getBrowserText(), displayName, userDetailsManager.getUserDetails(byUser).map(d -> "by " + d.getDisplayName()).orElse(""));
String emailBody = templateEngine.populateTemplate(watchTemplate.getContents(), templateObjects);
logger.info("{} Watch triggered by {} on {}. Notifying {}", projectId, byUser, modifiedEntity, usersToNotify);
sendMail.sendMail(emailAddresses, emailSubject, emailBody, MessageHeader.inReplyTo(projectId.getId()), MessageHeader.references(projectId.getId()));
}
Aggregations