Skip to content
Merged
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
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
MAIL_USERNAME: CHANGE_ME
MAIL_PASSWORD: CHANGE_ME

API_BASE_URL: ${API_BASE_URL:-http://localhost:8080}

SPRING_DATASOURCE_HIKARI_INITIALIZATION_FAIL_TIMEOUT: -1
depends_on:
mysql:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
Expand All @@ -27,6 +28,9 @@ public class EmailService {
private static final DateTimeFormatter DATE_FORMATTER =
DateTimeFormatter.ofPattern("dd/MM/yyyy").withZone(ZoneId.of("America/Sao_Paulo"));

@Value("${api.base-url}")
private String baseUrl;

public EmailService(MailEngine mailEngine, EmailSendFailureRepository emailSendFailureRepository) {
this.mailEngine = mailEngine;
this.emailSendFailureRepository = emailSendFailureRepository;
Expand All @@ -39,7 +43,9 @@ public void send(Reminder reminder) {

Contact contact = reminder.getUser().getContact();

Map<String, String> variables = buildEmailVariables(contact, reminder, "#");
String disableUrl = baseUrl + "/reminders/" + reminder.getId() + "/disable-notifications";

Map<String, String> variables = buildEmailVariables(contact, reminder, disableUrl);

MimeMessage mimeMessage = mailEngine.createEmailMessage(variables);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ public ResponseEntity<Void> delete(@PathVariable Long id) {
public ResponseEntity<Void> disableEmail(@PathVariable Long id) throws SchedulerException {
reminderService.disableReminderNotifications(id);
return ResponseEntity.noContent().build();

}
}
4 changes: 3 additions & 1 deletion src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

spring.mail.host=localhost
spring.mail.port=2525
spring.mail.port=2525

api.base-url=http://localhost:8080
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=always
spring.quartz.jdbc.initialize-schema=always

api.base.url=${API_BASE_URL:http://localhost:8080}