mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Changed that mailgun or smtp server can be used to send mails from server.
This commit is contained in:
parent
ba98d44772
commit
dcbe2da0e6
3 changed files with 30 additions and 7 deletions
|
@ -19,6 +19,17 @@
|
||||||
userNamePattern - pattern for user name validity check
|
userNamePattern - pattern for user name validity check
|
||||||
maxAiOpponents - number of allowed AI opponents on the server
|
maxAiOpponents - number of allowed AI opponents on the server
|
||||||
saveGameActivated - allow game save and replay options (not working correctly yet)
|
saveGameActivated - allow game save and replay options (not working correctly yet)
|
||||||
|
authenticationActivated - "true" = user have to register to signon "false" = user need not to register
|
||||||
|
* mail configs only needed if authentication is activated:
|
||||||
|
* if mailUser = "" mailgun is used otherwise nativ mail server on the system
|
||||||
|
googleAccount - not supported currently
|
||||||
|
mailgunApiKey - key from the mailgun domain e.g. = "key-12121111..."
|
||||||
|
mailgunDomain - domain for the mailgun message sending
|
||||||
|
mailSmtpHost - hostname to send the mail
|
||||||
|
mailSmtpPort - port to send the mail
|
||||||
|
mailUser - username used to send the mail
|
||||||
|
mailPassword - passworf of the used user to send the mail
|
||||||
|
mailFromAddress - sender address
|
||||||
-->
|
-->
|
||||||
<server serverAddress="0.0.0.0"
|
<server serverAddress="0.0.0.0"
|
||||||
serverName="mage-server"
|
serverName="mage-server"
|
||||||
|
|
|
@ -167,7 +167,12 @@ public class Main {
|
||||||
logger.info("Config - auth. activated : " + (config.isAuthenticationActivated() ? "true" : "false"));
|
logger.info("Config - auth. activated : " + (config.isAuthenticationActivated() ? "true" : "false"));
|
||||||
logger.info("Config - mailgun api key : " + config.getMailgunApiKey());
|
logger.info("Config - mailgun api key : " + config.getMailgunApiKey());
|
||||||
logger.info("Config - mailgun domain : " + config.getMailgunDomain());
|
logger.info("Config - mailgun domain : " + config.getMailgunDomain());
|
||||||
//logger.info("Config - google account : " + config.getGoogleAccount());
|
logger.info("Config - mail smtp Host : " + config.getMailSmtpHost());
|
||||||
|
logger.info("Config - mail smtpPort : " + config.getMailSmtpPort());
|
||||||
|
logger.info("Config - mail user : " + config.getMailUser());
|
||||||
|
logger.info("Config - mail passw. len.: " + config.getMailPassword().length());
|
||||||
|
logger.info("Config - mail from addre.: " + config.getMailFromAddress());
|
||||||
|
logger.info("Config - google account : " + config.getGoogleAccount());
|
||||||
|
|
||||||
Connection connection = new Connection("&maxPoolSize=" + config.getMaxPoolSize());
|
Connection connection = new Connection("&maxPoolSize=" + config.getMaxPoolSize());
|
||||||
connection.setHost(config.getServerAddress());
|
connection.setHost(config.getServerAddress());
|
||||||
|
@ -406,8 +411,8 @@ public class Main {
|
||||||
MatchProto match = table.getMatch();
|
MatchProto match = table.getMatch();
|
||||||
for (MatchPlayerProto player : match.getPlayersList()) {
|
for (MatchPlayerProto player : match.getPlayersList()) {
|
||||||
UserStats userStats = UserStatsRepository.instance.getUser(player.getName());
|
UserStats userStats = UserStatsRepository.instance.getUser(player.getName());
|
||||||
UserStatsProto proto = userStats != null ? userStats.getProto() :
|
UserStatsProto proto = userStats != null ? userStats.getProto()
|
||||||
UserStatsProto.newBuilder().setName(player.getName()).build();
|
: UserStatsProto.newBuilder().setName(player.getName()).build();
|
||||||
UserStatsProto.Builder builder = UserStatsProto.newBuilder(proto)
|
UserStatsProto.Builder builder = UserStatsProto.newBuilder(proto)
|
||||||
.setMatches(proto.getMatches() + 1);
|
.setMatches(proto.getMatches() + 1);
|
||||||
switch (player.getQuit()) {
|
switch (player.getQuit()) {
|
||||||
|
@ -436,8 +441,8 @@ public class Main {
|
||||||
TourneyProto tourney = table.getTourney();
|
TourneyProto tourney = table.getTourney();
|
||||||
for (TourneyPlayerProto player : tourney.getPlayersList()) {
|
for (TourneyPlayerProto player : tourney.getPlayersList()) {
|
||||||
UserStats userStats = UserStatsRepository.instance.getUser(player.getName());
|
UserStats userStats = UserStatsRepository.instance.getUser(player.getName());
|
||||||
UserStatsProto proto = userStats != null ? userStats.getProto() :
|
UserStatsProto proto = userStats != null ? userStats.getProto()
|
||||||
UserStatsProto.newBuilder().setName(player.getName()).build();
|
: UserStatsProto.newBuilder().setName(player.getName()).build();
|
||||||
UserStatsProto.Builder builder = UserStatsProto.newBuilder(proto)
|
UserStatsProto.Builder builder = UserStatsProto.newBuilder(proto)
|
||||||
.setTourneys(proto.getTourneys() + 1);
|
.setTourneys(proto.getTourneys() + 1);
|
||||||
switch (player.getQuit()) {
|
switch (player.getQuit()) {
|
||||||
|
|
|
@ -99,8 +99,15 @@ public class Session {
|
||||||
return returnMessage;
|
return returnMessage;
|
||||||
}
|
}
|
||||||
AuthorizedUserRepository.instance.add(userName, password, email);
|
AuthorizedUserRepository.instance.add(userName, password, email);
|
||||||
if (MailClient.sendMessage(email, "XMage Registration Completed",
|
String subject = "XMage Registration Completed";
|
||||||
"You are successfully registered as " + userName + ".")) {
|
String text = "You are successfully registered as " + userName + ".";
|
||||||
|
boolean success;
|
||||||
|
if (!ConfigSettings.getInstance().getMailUser().isEmpty()) {
|
||||||
|
success = MailClient.sendMessage(email, subject, text);
|
||||||
|
} else {
|
||||||
|
success = MailgunClient.sendMessage(email, subject, text);
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
logger.info("Sent a registration confirmation email to " + email + " for " + userName);
|
logger.info("Sent a registration confirmation email to " + email + " for " + userName);
|
||||||
} else {
|
} else {
|
||||||
logger.error("Failed sending a registration confirmation email to " + email + " for " + userName);
|
logger.error("Failed sending a registration confirmation email to " + email + " for " + userName);
|
||||||
|
|
Loading…
Reference in a new issue