diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index c63301c90..3bdf62676 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -399,6 +399,8 @@ public class WhisperServerService extends Application sendReceipt(AuthenticatedAccount source, UUID destinationUuid, long messageId) throws NoSuchUserException { final Account sourceAccount = source.getAccount(); if (sourceAccount.getUuid().equals(destinationUuid)) { - return; + return CompletableFuture.completedFuture(null); } final Account destinationAccount = accountManager.getByAccountIdentifier(destinationUuid) @@ -45,12 +50,16 @@ public class ReceiptSender { .setTimestamp(messageId) .setType(Envelope.Type.SERVER_DELIVERY_RECEIPT); - for (final Device destinationDevice : destinationAccount.getDevices()) { - try { - messageSender.sendMessage(destinationAccount, destinationDevice, message.build(), false); - } catch (final NotPushRegisteredException e) { - logger.info("User no longer push registered for delivery receipt: " + e.getMessage()); + return CompletableFuture.runAsync(() -> { + for (final Device destinationDevice : destinationAccount.getDevices()) { + try { + messageSender.sendMessage(destinationAccount, destinationDevice, message.build(), false); + } catch (final NotPushRegisteredException e) { + logger.info("User no longer push registered for delivery receipt: " + e.getMessage()); + } catch (final Exception e) { + logger.warn("Could not send delivery receipt", e); + } } - } + }, executor); } }