Skip to content

Commit

Permalink
fixes #162 global email from address and name
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Nov 8, 2017
1 parent 1150b4f commit 7a62bbb
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 27 deletions.
7 changes: 3 additions & 4 deletions src/inttest/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,19 @@ faf-api:
website-url-format: "http://example.com/%s"
user:
minimum-days-between-username-change: 30
mail:
from-email-name: "integration-test@faforever.com"
from-email-address: "integration-test@faforever.com"
password-reset:
password-reset-url-format: "http://localhost:8010/users/claimPasswordResetToken/%s"
success-redirect-url: "http://localhost/password_resetted"
subject: "Integration test password reset"
html-format: "Integration test password reset html body"
from-email: "integration-test@faforever.com"
from-name: "integration-test@faforever.com"
registration:
activation-url-format: "http://localhost/users/activate?token=%s"
success-redirect-url: "http://localhost/account_activated"
subject: "Integration test registration"
html-format: "Integration test registration html body"
from-email: "integration-test@faforever.com"
from-name: "integration-test@faforever.com"
link-to-steam:
steam-redirect-url-format: "http://localhost:8010/users/linkToSteam?token=%s"
success-redirect-url: "http://localhost/linked_to_steam"
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/faforever/api/config/FafApiProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static class FeaturedMod {

@Data
public static class Clan {
private long inviteLinkExpireDurationMinutes = Duration.ofDays(3).toMinutes();
private long inviteLinkExpireDurationMinutes = Duration.ofDays(7).toMinutes();
private String websiteUrlFormat;
}

Expand All @@ -142,6 +142,8 @@ public static class Deployment {

@Data
public static class Mail {
private String fromEmailAddress;
private String fromEmailName;
private String mandrillApiKey;
}

Expand All @@ -151,8 +153,6 @@ public static class Registration {
private String activationUrlFormat;
private String subject;
private String htmlFormat;
private String fromEmail;
private String fromName;
private String successRedirectUrl;
}

Expand All @@ -162,8 +162,6 @@ public static class PasswordReset {
private String passwordResetUrlFormat;
private String subject;
private String htmlFormat;
private String fromEmail;
private String fromName;
private String successRedirectUrl;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/faforever/api/email/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void validateEmailAddress(String email) {
public void sendActivationMail(String username, String email, String activationUrl) {
Registration registration = properties.getRegistration();
emailSender.sendMail(
registration.getFromEmail(),
registration.getFromName(),
properties.getMail().getFromEmailAddress(),
properties.getMail().getFromEmailName(),
email,
registration.getSubject(),
MessageFormat.format(registration.getHtmlFormat(), username, activationUrl)
Expand All @@ -57,8 +57,8 @@ public void sendActivationMail(String username, String email, String activationU
public void sendPasswordResetMail(String username, String email, String passwordResetUrl) {
PasswordReset passwordReset = properties.getPasswordReset();
emailSender.sendMail(
passwordReset.getFromEmail(),
passwordReset.getFromName(),
properties.getMail().getFromEmailAddress(),
properties.getMail().getFromEmailName(),
email,
passwordReset.getSubject(),
MessageFormat.format(passwordReset.getHtmlFormat(), username, passwordResetUrl)
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ faf-api:
featured-mods-target-directory: ${FEATURED_MODS_TARGET_DIRECTORY:build/cache/deployment}
clan:
website-url-format: ${CLAN_WEBSITE_URL_FORMAT:http://clans.test.faforever.com/clan/%s}
mail:
from-email-name: ${EMAIL_FROM_ADDRESS:unit-test@faforever.com}
from-email-address: ${EMAIL_FROM_NAME:unit-test@faforever.com}
registration:
activation-url-format: ${ACTIVATION_URL_FORMAT:http://localhost:8010/users/activate/%s}
success-redirect-url: ${ACTIVATION_SUCCESS_REDIRECT_URL:http://localhost:8020/account_activated}
subject: "Unit test registration"
html-format: "Unit test registration html body"
from-email: "unit-test@faforever.com"
from-name: "unit-test@faforever.com"
password-reset:
password-reset-url-format: ${PASSWORD_RESET_URL_FORMAT:http://localhost:8010/users/claimPasswordResetToken/%s}
success-redirect-url: ${PASSWORD_RESET_SUCCESS_REDIRECT_URL:http://localhost:8020/password_resetted}
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ faf-api:
forged-alliance-exe-path: ${FORGED_ALLIANCE_EXE_PATH}
repositories-directory: ${REPOSITORIES_DIRECTORY}
featured-mods-target-directory: ${FEATURED_MODS_TARGET_DIRECTORY}
mail:
from-email-name: ${EMAIL_FROM_ADDRESS}
from-email-address: ${EMAIL_FROM_NAME}
registration:
activation-url-format: ${ACTIVATION_URL_FORMAT}
subject: ${REGISTRATION_EMAIL_SUBJECT}
html-format: ${REGISTRATION_EMAIL_BODY}
from-email: ${REGISTRATION_EMAIL_FROM_EMAIL}
from-name: ${REGISTRATION_EMAIL_FROM_NAME}
password-reset:
password-reset-url-format: ${PASSWORD_RESET_URL_FORMAT}
mail:
Expand Down
6 changes: 0 additions & 6 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
faf-api:
version: #faf-api.version#
registration:
subject: Account activation
from-email: admin@faforever.com
from-name: Forged Alliance Forever
link-expiration-seconds: 86400
html-format: <p>Dear %1$s,</p><p>welcome to the Forged Alliance Forever community. Please visit the following link to activate your account:</p><p><a href="%2$s">%2$s</a></p><p>-- The Forged Alliance Forever team.</p>
clan:
invite-link-expire-duration-minutes: ${CLAN_INVITE_LINK_EXPIRE_DURATION_MINUTES:604800}
challonge:
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/com/faforever/api/email/EmailServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class EmailServiceTest {
@Before
public void setUp() throws Exception {
properties = new FafApiProperties();
properties.getMail().setFromEmailAddress("foo@bar.com");
properties.getMail().setFromEmailName("foobar");

instance = new EmailService(domainBlacklistRepository, properties, emailSender);
}
Expand Down Expand Up @@ -65,8 +67,6 @@ public void validateEmailAddressBlacklisted() throws Exception {
@Test
public void sendActivationMail() throws Exception {
Registration registration = properties.getRegistration();
registration.setFromEmail("foo@bar.com");
registration.setFromName("foobar");
registration.setSubject("Hello");
registration.setHtmlFormat("Hello {0}, bla: {1}");

Expand All @@ -78,8 +78,6 @@ public void sendActivationMail() throws Exception {
@Test
public void sendPasswordResetMail() {
PasswordReset passwordReset = properties.getPasswordReset();
passwordReset.setFromEmail("foo@bar.com");
passwordReset.setFromName("foobar");
passwordReset.setSubject("Hello");
passwordReset.setHtmlFormat("Hello {0}, bla: {1}");

Expand Down

0 comments on commit 7a62bbb

Please sign in to comment.