#655 Encapsulate mail service

- Change SendMailSSL to be injected into classes and created regardless of settings
- Various minor cleanups (remove accidentally committed test, add more precise logging statement)
This commit is contained in:
ljacqu
2016-07-02 20:56:53 +02:00
parent d2556b8a04
commit 9a5c432509
9 changed files with 80 additions and 72 deletions
@@ -1,12 +1,12 @@
package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.mail.SendMailSSL;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.RandomString;
@@ -33,15 +33,14 @@ public class RecoverEmailCommand extends PlayerCommand {
private PlayerCache playerCache;
@Inject
// TODO #655: Remove injected AuthMe instance once Authme#mail is encapsulated
private AuthMe plugin;
private SendMailSSL sendMailSsl;
@Override
public void runCommand(Player player, List<String> arguments) {
final String playerMail = arguments.get(0);
final String playerName = player.getName();
if (plugin.getMail() == null) {
if (!sendMailSsl.hasAllInformation()) {
ConsoleLogger.showError("Mail API is not set");
commandService.send(player, MessageKey.ERROR);
return;
@@ -76,7 +75,7 @@ public class RecoverEmailCommand extends PlayerCommand {
}
auth.setPassword(hashNew);
dataSource.updatePassword(auth);
plugin.getMail().main(auth, thePass);
sendMailSsl.sendPasswordMail(auth, thePass);
commandService.send(player, MessageKey.RECOVERY_EMAIL_SENT_MESSAGE);
} else {
commandService.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);