|
|
@@ -18,6 +18,7 @@ import bubble.model.account.message.handlers.*; |
|
|
|
import bubble.model.cloud.CloudService; |
|
|
|
import bubble.server.BubbleConfiguration; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.NonNull; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.cobbzilla.util.collection.NameAndValue; |
|
|
|
import org.cobbzilla.util.string.StringUtil; |
|
|
@@ -47,7 +48,29 @@ public class StandardAccountMessageService implements AccountMessageService { |
|
|
|
@Autowired private CloudServiceDAO cloudDAO; |
|
|
|
@Autowired private BubbleConfiguration configuration; |
|
|
|
|
|
|
|
/** |
|
|
|
* If returns true, then email/sms will NOT be sent out for this AccountMessage object. |
|
|
|
*/ |
|
|
|
private boolean isQuietMessage(@NonNull final AccountMessage message) { |
|
|
|
if (message.getMessageType() == AccountMessageType.confirmation |
|
|
|
&& message.getAction() == AccountAction.welcome |
|
|
|
&& message.getTarget() == ActionTarget.account) { |
|
|
|
// No need for confirmation message here. The end user received `request.welcome.account` message with email |
|
|
|
// address verification link. When he clicked the link, then the request was approved. That was the only |
|
|
|
// required approval, and so it was also confirmed at that moment. Hence, AccountMessage |
|
|
|
// `confirmation.welcome.account` is created. But there no real need to send out email at this point to the |
|
|
|
// same user. And so this other confirmation message is `quiet`. |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
@Override public boolean send(AccountMessage message) { |
|
|
|
if (isQuietMessage(message)) { |
|
|
|
log.info("send(" + message + "): message marked as quiet"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
final String accountUuid = message.getAccount(); |
|
|
|
final Account account = accountDAO.findByUuid(accountUuid); |
|
|
|
AccountPolicy policy = policyDAO.findSingleByAccount(accountUuid); |
|
|
|