diff --git a/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java b/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java index af6c98a9..c509d224 100644 --- a/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java +++ b/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java @@ -167,13 +167,15 @@ public class StandardAccountMessageService implements AccountMessageService { approval.setRequestContact(policy.findContactByUuid(approval.getRequest().getContact())); getCompletionHandler(approval).confirm(approval, data); - final AccountMessage confirm = messageDAO.create( - new AccountMessage(approval).setMessageType(AccountMessageType.confirmation)); + final AccountMessage confirm = new AccountMessage(approval).setMessageType(AccountMessageType.confirmation); if (approval.hasConfirmationTokensToRemove()) { final RedisService tokens = getConfirmationTokens(); for (String toRemove : approval.getConfirmationTokensToRemove()) tokens.del(toRemove); } - return confirm; + + // Write AccountMessage entity into database only if Account is still available in there + // (i.e. not removed with block_delete deletion policy) + return accountDAO.exists(confirm.getAccount()) ? messageDAO.create(confirm) : confirm; } else if (approvalStatus.ok()) { if (approval.hasConfirmationTokensToRemove()) {