Skip to content

Commit

Permalink
feat: allow a different support email for tenant and owner
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien committed Oct 30, 2024
1 parent 9e847ca commit 50c4890
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import jakarta.servlet.Filter;
import jakarta.servlet.annotation.WebFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

@Component
@Profile("!dev")
@WebFilter("/api/register/account")
public class RateLimitingFilter extends AbstractRateLimitingFilter implements Filter {
@Value("${ratelimit.register.capacity}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import jakarta.servlet.Filter;
import jakarta.servlet.annotation.WebFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

@Component
@Profile("!dev")
@WebFilter("/api/support/email")
public class RateLimitingSupportMailFilter extends AbstractRateLimitingFilter implements Filter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public class ContactForm {
@JsonDeserialize(using = EmailDeserializer.class)
String email;
@NotEmpty
String profile;
Profile profile;
@NotEmpty
String subject;
@NotEmpty
String message;
public enum Profile {
tenant, owner
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
import org.springframework.stereotype.Service;

import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;

import static fr.dossierfacile.common.enums.ApplicationType.COUPLE;
import static fr.dossierfacile.common.enums.ApplicationType.GROUP;
Expand All @@ -40,6 +36,8 @@ public class MailServiceImpl implements MailService {
private String tenantBaseUrl;
@Value("${email.support}")
private String emailSupport;
@Value("${email.support.owner}")
private String emailSupportOwner;
@Value("${brevo.template.id.welcome}")
private Long templateIDWelcome;
@Value("${brevo.template.id.welcome.partner}")
Expand Down Expand Up @@ -233,12 +231,16 @@ public void sendEmailToSupport(ContactForm form) {
variables.put("firstname", form.getFirstname());
variables.put("lastname", form.getLastname());
variables.put("email", form.getEmail());
variables.put("profile", form.getProfile());
if (form.getProfile() != null) {
variables.put("profile", form.getProfile().name());
}
variables.put("subject", form.getSubject());
variables.put("message", form.getMessage());

SendSmtpEmailTo sendSmtpEmailTo = new SendSmtpEmailTo();
sendSmtpEmailTo.setEmail(emailSupport);

String recipientEmail = (ContactForm.Profile.owner == form.getProfile()) ? emailSupportOwner : emailSupport;
sendSmtpEmailTo.setEmail(recipientEmail);
sendSmtpEmailTo.setName("Support depuis formulaire");

SendSmtpEmailReplyTo sendSmtpEmailReplyTo = new SendSmtpEmailReplyTo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ spring.cache.caffeine.treated-files-by-operator-key.expire-after-write=5m


# Emails
email.support=
email.support.owner=
link.after.completed.default=
link.after.created.default=

Expand Down

0 comments on commit 50c4890

Please sign in to comment.