Skip to content

Commit

Permalink
Make anope database name configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed May 17, 2018
1 parent 7190242 commit 9ef97c4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ apply plugin: 'propdeps'
apply plugin: 'idea'

group = 'faforever'
version = '1.3.1'
version = '1.3.2'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/faforever/api/config/FafApiProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class FafApiProperties {
private User user = new User();
private Database database = new Database();
private Mautic mautic = new Mautic();
private Anope anope = new Anope();

@Data
public static class OAuth2 {
Expand Down Expand Up @@ -222,4 +223,9 @@ public static class Mautic {
private String clientSecret;
private String accessTokenUrl;
}

@Data
public class Anope {
private String databaseName;
}
}
7 changes: 5 additions & 2 deletions src/main/java/com/faforever/api/user/AnopeUserRepository.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.faforever.api.user;

import com.faforever.api.config.FafApiProperties;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
Expand All @@ -13,14 +14,16 @@
public class AnopeUserRepository {

private final NamedParameterJdbcTemplate jdbcTemplate;
private String anopeDatabaseName;

public AnopeUserRepository(NamedParameterJdbcTemplate jdbcTemplate) {
public AnopeUserRepository(NamedParameterJdbcTemplate jdbcTemplate, FafApiProperties properties) {
this.jdbcTemplate = jdbcTemplate;
anopeDatabaseName = properties.getAnope().getDatabaseName();
}

// Don't make this package private, see https://jira.spring.io/browse/SPR-15911
public void updatePassword(String username, String password) {
jdbcTemplate.update("UPDATE `faf-anope`.anope_db_NickCore SET pass = :password WHERE display = :username",
jdbcTemplate.update("UPDATE `" + anopeDatabaseName + "`.anope_db_NickCore SET pass = :password WHERE display = :username",
ImmutableMap.of(
"password", password,
"username", username
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ faf-api:
git-hub:
access-token: ${GITHUB_ACCESS_TOKEN:false}
webhook-secret: ${GITHUB_WEBHOOK_SECRET:false}
anope:
database-name: ${ANOPE_DATABASE_NAME:faf-anope}

spring:
application:
Expand Down

0 comments on commit 9ef97c4

Please sign in to comment.