Skip to content

Commit

Permalink
Improve bean condition for MauticService and NoopEmailSender
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed May 6, 2018
1 parent b0077cf commit 1d6ace0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/faforever/api/config/GitHubConfig.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.faforever.api.config;

import org.kohsuke.github.GitHub;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import java.io.IOException;

@Configuration
public class GitHubConfig {
@Bean
@Profile("!" + ApplicationProfile.DEVELOPMENT)
@ConditionalOnProperty(value = "faf-api.git-hub.access-token")
public GitHub gitHub(FafApiProperties fafApiProperties) throws IOException {
return GitHub.connectUsingOAuth(fafApiProperties.getGitHub().getAccessToken());
}

@Bean
@Profile(ApplicationProfile.DEVELOPMENT)
@ConditionalOnProperty(value = "faf-api.git-hub.access-token", havingValue = "false", matchIfMissing = true)
public GitHub offlineGitHub() {
return GitHub.offline();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/faforever/api/email/NoopEmailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Service
@Slf4j
@ConditionalOnProperty(value = "faf-api.mail.mandrill-api-key", matchIfMissing = true)
@ConditionalOnProperty(value = "faf-api.mail.mandrill-api-key", havingValue = "false", matchIfMissing = true)
public class NoopEmailSender implements EmailSender {
@Override
public void sendMail(String fromEmail, String fromName, String toEmail, String subject, String content) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ faf-api:
download-url-format: ${AVATAR_DOWNLOAD_URL_FORMAT:http://content.test.faforever.com/faf/avatars/%s}
target-directory: ${AVATAR_TARGET_DIRECTORY:build/cache/avatars}
allowed-extensions: ${AVATAR_ALLOWED_FILE_EXTENSIONS:png}
max-size-bytes: ${AVATAR_MAX_SIZE_BYTES:4096}
image-width: ${AVATAR_IMAGE_WIDTH:40}
image-height: ${AVATAR_IMAGE_HEIGHT:20}
featured-mod:
file-url-format: ${FEATURED_MOD_URL_FORMAT:http://content.test.faforever.com/faf/updaterNew/%s/%s}
bireus-url-format: ${FEATURED_MOD_BIREUS_URL_FORMAT:https://content.test.faforever.com/repositories/%s}
Expand Down
12 changes: 2 additions & 10 deletions src/main/resources/config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ faf-api:
download-url-format: ${AVATAR_DOWNLOAD_URL_FORMAT}
target-directory: ${AVATAR_TARGET_DIRECTORY}
allowed-extensions: ${AVATAR_ALLOWED_FILE_EXTENSIONS}
max-size-bytes: ${AVATAR_MAX_SIZE_BYTES}
image-width: ${AVATAR_IMAGE_WIDTH}
image-height: ${AVATAR_IMAGE_HEIGHT}
featured-mod:
file-url-format: ${FEATURED_MOD_URL_FORMAT}
bireus-url-format: ${FEATURED_MOD_BIREUS_URL_FORMAT}
git-hub:
access-token: ${GITHUB_ACCESS_TOKEN}
access-token: ${GITHUB_ACCESS_TOKEN:false}
deployment-environment: ${GITHUB_DEPLOYMENT_ENVIRONMENT:production}
webhook-secret: ${GITHUB_WEBHOOK_SECRET}
webhook-secret: ${GITHUB_WEBHOOK_SECRET:false}
deployment:
forged-alliance-exe-path: ${FORGED_ALLIANCE_EXE_PATH}
repositories-directory: ${REPOSITORIES_DIRECTORY}
Expand Down Expand Up @@ -56,11 +53,6 @@ faf-api:
steam-redirect-url-format: ${STEAM_LINK_REDIRECT_URL}
success-redirect-url: ${STEAM_LINK_SUCCESS_URL}
error-redirect-url-format: ${STEAM_LINK_ERROR_URL}
mautic:
base-url: ${MAUTIC_BASE_URL}
client-id: ${MAUTIC_CLIENT_ID}
client-secret: ${MAUTIC_CLIENT_SECRET}
access-token-url: ${MAUTIC_ACCESS_TOKEN_URL}

spring:
datasource:
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
faf-api:
version: #faf-api.version#
avatar:
max-size-bytes: ${AVATAR_MAX_SIZE_BYTES:4096}
image-width: ${AVATAR_IMAGE_WIDTH:40}
image-height: ${AVATAR_IMAGE_HEIGHT:20}
clan:
invite-link-expire-duration-minutes: ${CLAN_INVITE_LINK_EXPIRE_DURATION_MINUTES:604800}
challonge:
key: ${CHALLONGE_KEY:}
database:
schema-version: ${DATABASE_SCHEMA_VERSION:48}
mautic:
base-url: ${MAUTIC_BASE_URL:false}
client-id: ${MAUTIC_CLIENT_ID:false}
client-secret: ${MAUTIC_CLIENT_SECRET:false}
access-token-url: ${MAUTIC_ACCESS_TOKEN_URL:false}

spring:
application:
Expand Down

0 comments on commit 1d6ace0

Please sign in to comment.