Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular reference in userService #950 #951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions services/src/main/java/fr/ippon/tatami/service/MailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import fr.ippon.tatami.domain.User;
import fr.ippon.tatami.domain.status.AbstractStatus;
import fr.ippon.tatami.domain.status.Status;
import fr.ippon.tatami.repository.DomainRepository;
import fr.ippon.tatami.repository.UserRepository;
import fr.ippon.tatami.security.AuthenticationService;
import fr.ippon.tatami.security.TatamiUserDetailsService;
import fr.ippon.tatami.service.dto.StatusDTO;
import fr.ippon.tatami.service.util.DomainUtil;
import org.apache.velocity.app.VelocityEngine;
Expand Down Expand Up @@ -47,15 +43,6 @@ public class MailService {
@Inject
private MessageSource mailMessageSource;

@Inject
private AuthenticationService authenticationService;

@Inject
private UserService userService;

@Inject
private DomainRepository domainRepository;

private String host;

private int port;
Expand All @@ -79,8 +66,6 @@ public class MailService {
@Inject
private VelocityEngine velocityEngine;

@Inject
private TatamiUserDetailsService tatamiUserDetailsService;

@PostConstruct
public void init() {
Expand Down Expand Up @@ -112,17 +97,6 @@ public void sendRegistrationEmail(String registrationKey, User user) {
sendTextFromTemplate(user.getLogin(), model, "registration", this.locale);
}

@Async
public void sendInvitationEmail(String email, User user) {
log.debug("Sending invitation e-mail to email '{}'", email);

Map<String, Object> model = new HashMap<String, Object>();
model.put("user", user.getLogin());
model.put("invitationUrl", tatamiUrl);

sendTextFromTemplate(user.getLogin(), model, "invitationMessage", this.locale);
}

@Async
public void sendLostPasswordEmail(String registrationKey, User user) {

Expand Down Expand Up @@ -221,15 +195,15 @@ public void sendWeeklyDigestEmail(User user, List<StatusDTO> statuses, int nbSta
}

@Async
public void sendReportedStatusEmail(String emailReporting, AbstractStatus status) {
public void sendReportedStatusEmail(String emailReporting, AbstractStatus status,Collection<String> adminUser) {
log.debug("Sending reported status e-mail to User '{}' with locale : '{}'", locale);
String url = tatamiUrl + "/#/home/status/" + status.getStatusId();

Map<String, Object> model = new HashMap<String, Object>();
model.put("status", status);
model.put("statusUrl", url);

for(String email : tatamiUserDetailsService.getAdminUsers()) {
for(String email : adminUser) {
sendTextFromTemplate(email, model, "reportedStatus", this.locale);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import fr.ippon.tatami.domain.status.*;
import fr.ippon.tatami.repository.*;
import fr.ippon.tatami.security.AuthenticationService;
import fr.ippon.tatami.security.TatamiUserDetailsService;
import fr.ippon.tatami.service.dto.StatusDTO;
import fr.ippon.tatami.service.exception.ArchivedGroupException;
import fr.ippon.tatami.service.exception.ReplyStatusException;
import fr.ippon.tatami.service.util.DomainUtil;
import org.apache.camel.util.Time;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.openjpa.jdbc.kernel.exps.Abs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -107,7 +106,7 @@ public class StatusUpdateService {
private StatusReportRepository statusReportRepository;

@Inject
private BlockRepository blockRepository;
private TatamiUserDetailsService tatamiUserDetailsService;

@Inject
private TimelineService timelineService;
Expand Down Expand Up @@ -429,7 +428,7 @@ public void reportStatus(String reportingLogin, String statusId) {
log.debug("Reported Status: ", statusId);
String domain = DomainUtil.getDomainFromLogin(reportingLogin);
statusReportRepository.reportStatus(domain, statusId, reportingLogin);
mailService.sendReportedStatusEmail(reportingLogin, statusRepository.findStatusById(statusId));
mailService.sendReportedStatusEmail(reportingLogin, statusRepository.findStatusById(statusId),tatamiUserDetailsService.getAdminUsers());

}

Expand Down