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().getTimestamp());
}
} catch (NotPushRegisteredException e) {
logger.info("User no longer push registered for delivery receipt: " + e.getMessage());
} catch (NoSuchUserException e) {
logger.warn("Sending delivery receipt", e);
}
@ -223,8 +221,6 @@ public class MessageController {
}
} catch (NoSuchUserException 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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.controllers.NoSuchUserException;
import org.whispersystems.textsecuregcm.entities.MessageProtos.Envelope;
import org.whispersystems.textsecuregcm.storage.Account;
@ -7,12 +9,13 @@ import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.Device;
import java.util.Optional;
import java.util.Set;
public class ReceiptSender {
private final PushSender pushSender;
private final AccountsManager accountManager;
private final PushSender pushSender;
private final AccountsManager accountManager;
private static final Logger logger = LoggerFactory.getLogger(ReceiptSender.class);
public ReceiptSender(AccountsManager accountManager,
PushSender pushSender)
@ -22,14 +25,13 @@ public class ReceiptSender {
}
public void sendReceipt(Account source, String destination, long messageId)
throws NoSuchUserException, NotPushRegisteredException
throws NoSuchUserException
{
if (source.getNumber().equals(destination)) {
return;
}
Account destinationAccount = getDestinationAccount(destination);
Set<Device> destinationDevices = destinationAccount.getDevices();
Envelope.Builder message = Envelope.newBuilder()
.setSource(source.getNumber())
.setSourceUuid(source.getUuid().toString())
@ -41,8 +43,12 @@ public class ReceiptSender {
message.setRelay(source.getRelay().get());
}
for (Device destinationDevice : destinationDevices) {
pushSender.sendMessage(destinationAccount, destinationDevice, message.build(), false);
for (final Device destinationDevice : destinationAccount.getDevices()) {
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 {
receiptSender.sendReceipt(account, message.getSource(), message.getTimestamp());
} catch (NoSuchUserException | NotPushRegisteredException e) {
} catch (NoSuchUserException e) {
logger.info("No longer registered " + e.getMessage());
} catch (WebApplicationException e) {
logger.warn("Bad federated response for receipt: " + e.getResponse().getStatus());