Parcourir la source

Fix SMTP service compatible check method

pull/61/head
Kristijan Mitrovic il y a 4 ans
Parent
révision
f869a1d467
3 fichiers modifiés avec 15 ajouts et 7 suppressions
  1. +3
    -1
      bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java
  2. +9
    -6
      bubble-server/src/main/java/bubble/cloud/email/SmtpEmailDriver.java
  3. +3
    -0
      bubble-server/src/main/java/bubble/cloud/email/mock/MockEmailDriver.java

+ 3
- 1
bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java Voir le fichier

@@ -34,7 +34,9 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver {
@Autowired private AccountDAO accountDAO;
@Autowired private CloudServiceDAO serviceDAO;

@Override protected boolean isServiceCompatible() { return this.config.getHost().equals(SENDGRID_SMTP); }
@Override protected boolean isServiceCompatible(final String serviceHost) {
return SENDGRID_SMTP.equals(serviceHost);
}

/**
* Build username which will be used for Subuser created on SendGrid's service for specified Account's object.


+ 9
- 6
bubble-server/src/main/java/bubble/cloud/email/SmtpEmailDriver.java Voir le fichier

@@ -10,9 +10,8 @@ import bubble.cloud.email.mock.MockMailSender;
import bubble.model.account.Account;
import bubble.model.account.AccountContact;
import bubble.model.account.message.AccountMessage;
import bubble.model.cloud.CloudService;
import bubble.model.cloud.CloudCredentials;
import bubble.server.BubbleConfiguration;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.cobbzilla.mail.sender.SmtpMailSender;
@@ -49,12 +48,16 @@ public class SmtpEmailDriver extends CloudServiceDriverBase<EmailDriverConfig> i
return smtpSender;
}

@Override public void setConfig(JsonNode json, CloudService cloudService) {
super.setConfig(json, cloudService);
if (!isServiceCompatible()) die("Specified SmtpEmailDriver is not compatible with given config");
@Override public void setCredentials(CloudCredentials credentials) {
super.setCredentials(credentials);
if (credentials != null && !isServiceCompatible(credentials.getParam(PARAM_HOST))) {
die("Specified Smtp Email Driver is not compatible with given config: " + this.getClass().getSimpleName());
}
}

protected boolean isServiceCompatible() { return !SEPARATE_DRIVERS_SMTPS.contains(this.config.getHost()); }
protected boolean isServiceCompatible(final String serviceHost) {
return !SEPARATE_DRIVERS_SMTPS.contains(serviceHost);
}

@Override public boolean send(Account account, AccountMessage message, AccountContact contact) {
return EmailServiceDriver.send(this, account, message, contact);


+ 3
- 0
bubble-server/src/main/java/bubble/cloud/email/mock/MockEmailDriver.java Voir le fichier

@@ -7,10 +7,13 @@ package bubble.cloud.email.mock;
import bubble.cloud.email.SmtpEmailDriver;
import org.cobbzilla.mail.sender.SmtpMailSender;

import static org.cobbzilla.util.daemon.ZillaRuntime.empty;

public class MockEmailDriver extends SmtpEmailDriver {

private static final MockMailSender MOCK_MAIL_SENDER = new MockMailSender();

@Override public SmtpMailSender getSender() { return MOCK_MAIL_SENDER; }

@Override protected boolean isServiceCompatible(final String serviceHost) { return empty(serviceHost); }
}

Chargement…
Annuler
Enregistrer