Commit 82f53276 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fetch proper project when sending email

parent b9c02b5f
Pipeline #12110 passed with stage
in 8 minutes and 43 seconds
......@@ -14,8 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.common.ObjectUtils;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.map.CommentDao;
import lcsb.mapviewer.services.interfaces.*;
......@@ -93,9 +92,20 @@ public class CommentService implements ICommentService {
commentDao.add(comment);
try {
Project project = submodel.getProject();
if (project == null) {
for (SubmodelConnection sc : submodel.getParentModels()) {
if (sc instanceof ModelSubmodelConnection) {
project = ((ModelSubmodelConnection) sc).getParentModel().getModel().getProject();
if (project != null) {
break;
}
}
}
}
EmailSender emailSender = new EmailSender(configurationService);
emailSender.sendEmail("New comment appeard in the " + submodel.getProject().getProjectId(), content,
submodel.getProject().getNotifyEmail());
emailSender.sendEmail("New comment appeard in the " + project.getProjectId(), content, project.getNotifyEmail());
} catch (MessagingException e) {
logger.error("Problem with sending email.", e);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment