diff --git a/bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java b/bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java index 9a521fb8..508ecd0d 100644 --- a/bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java +++ b/bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java @@ -10,7 +10,6 @@ import lombok.*; import org.cobbzilla.util.http.HttpMethods; import org.cobbzilla.util.http.HttpRequestBean; import org.cobbzilla.util.http.HttpResponseBean; -import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.Nullable; import java.io.IOException; @@ -31,9 +30,6 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver { private static final String PARAM_PARENT_SERVICE = "parentService"; - @Autowired private AccountDAO accountDAO; - @Autowired private CloudServiceDAO serviceDAO; - @Override protected boolean isServiceCompatible(final String serviceHost) { return SENDGRID_SMTP.equals(serviceHost); } @@ -53,7 +49,8 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver { return super.setupDelegatedCloudService(configuration, parentService, delegatedService); } - final Account accountWithDelegate = accountDAO.findByUuid(delegatedService.getAccount()); + final Account accountWithDelegate = configuration.getBean(AccountDAO.class) + .findByUuid(delegatedService.getAccount()); final String user = sgUsername(delegatedService); String password = generatePassword(MIN_KEY_LENGTH, MIN_DISTINCT_LENGTH); final CreateSubuserRequest data = new CreateSubuserRequest(user, accountWithDelegate.getEmail(), password, @@ -70,10 +67,16 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver { } @Override public void postServiceDelete(@NonNull final CloudService service) { + // TODO: there must be configuration present here. If this happens, try some other way: + if (getConfiguration() == null) { + die("postServiceDelete: Cannot do this action with server configuration set within"); + } + final String parentServiceUuid = service.getCredentials().getParam(PARAM_PARENT_SERVICE); if (parentServiceUuid == null) return; - final CloudService parentService = serviceDAO.findByUuid(parentServiceUuid); + final CloudService parentService = getConfiguration().getBean(CloudServiceDAO.class) + .findByUuid(parentServiceUuid); if (parentService == null) return; final String sgUserToDelete = sgUsername(service);