Don't let one unregistered device block receipt for others.

This commit is contained in:
Jon Chambers 2020-04-30 18:12:50 -04:00 committed by Jon Chambers
parent acfbab5915
commit 10840b22c5
3 changed files with 14 additions and 12 deletions

View File

@ -200,8 +200,6 @@ public class MessageController {
message.get().getSource(), message.get().getSource(),
message.get().getTimestamp()); message.get().getTimestamp());
} }
} catch (NotPushRegisteredException e) {
logger.info("User no longer push registered for delivery receipt: " + e.getMessage());
} catch (NoSuchUserException e) { } catch (NoSuchUserException e) {
logger.warn("Sending delivery receipt", e); logger.warn("Sending delivery receipt", e);
} }
@ -223,8 +221,6 @@ public class MessageController {
} }
} catch (NoSuchUserException e) { } catch (NoSuchUserException e) {
logger.warn("Sending delivery receipt", e); logger.warn("Sending delivery receipt", e);
} catch (NotPushRegisteredException e) {
logger.info("User no longer push registered for delivery receipt: " + e.getMessage());
} }
} }

View File

@ -1,5 +1,7 @@
package org.whispersystems.textsecuregcm.push; package org.whispersystems.textsecuregcm.push;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.controllers.NoSuchUserException; import org.whispersystems.textsecuregcm.controllers.NoSuchUserException;
import org.whispersystems.textsecuregcm.entities.MessageProtos.Envelope; import org.whispersystems.textsecuregcm.entities.MessageProtos.Envelope;
import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.storage.Account;
@ -7,12 +9,13 @@ import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.Device; import org.whispersystems.textsecuregcm.storage.Device;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
public class ReceiptSender { public class ReceiptSender {
private final PushSender pushSender; private final PushSender pushSender;
private final AccountsManager accountManager; private final AccountsManager accountManager;
private static final Logger logger = LoggerFactory.getLogger(ReceiptSender.class);
public ReceiptSender(AccountsManager accountManager, public ReceiptSender(AccountsManager accountManager,
PushSender pushSender) PushSender pushSender)
@ -22,14 +25,13 @@ public class ReceiptSender {
} }
public void sendReceipt(Account source, String destination, long messageId) public void sendReceipt(Account source, String destination, long messageId)
throws NoSuchUserException, NotPushRegisteredException throws NoSuchUserException
{ {
if (source.getNumber().equals(destination)) { if (source.getNumber().equals(destination)) {
return; return;
} }
Account destinationAccount = getDestinationAccount(destination); Account destinationAccount = getDestinationAccount(destination);
Set<Device> destinationDevices = destinationAccount.getDevices();
Envelope.Builder message = Envelope.newBuilder() Envelope.Builder message = Envelope.newBuilder()
.setSource(source.getNumber()) .setSource(source.getNumber())
.setSourceUuid(source.getUuid().toString()) .setSourceUuid(source.getUuid().toString())
@ -41,8 +43,12 @@ public class ReceiptSender {
message.setRelay(source.getRelay().get()); message.setRelay(source.getRelay().get());
} }
for (Device destinationDevice : destinationDevices) { for (final Device destinationDevice : destinationAccount.getDevices()) {
pushSender.sendMessage(destinationAccount, destinationDevice, message.build(), false); try {
pushSender.sendMessage(destinationAccount, destinationDevice, message.build(), false);
} catch (NotPushRegisteredException e) {
logger.info("User no longer push registered for delivery receipt: " + e.getMessage());
}
} }
} }

View File

@ -158,7 +158,7 @@ public class WebSocketConnection implements DispatchChannel {
try { try {
receiptSender.sendReceipt(account, message.getSource(), message.getTimestamp()); receiptSender.sendReceipt(account, message.getSource(), message.getTimestamp());
} catch (NoSuchUserException | NotPushRegisteredException e) { } catch (NoSuchUserException e) {
logger.info("No longer registered " + e.getMessage()); logger.info("No longer registered " + e.getMessage());
} catch (WebApplicationException e) { } catch (WebApplicationException e) {
logger.warn("Bad federated response for receipt: " + e.getResponse().getStatus()); logger.warn("Bad federated response for receipt: " + e.getResponse().getStatus());