Send delivery receipt for data messages that need it

With the unidentified sender messages, the Signal server cannot do this
automatically anymore.
This commit is contained in:
AsamK 2020-03-23 20:49:38 +01:00
parent b62694dbc7
commit 1b56485fc8

View file

@ -80,6 +80,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceContent;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifestUpload;
import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifestUpload.StickerInfo;
import org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage;
@ -668,6 +669,14 @@ public class Manager implements Signal {
sendMessageLegacy(messageBuilder, Collections.singleton(recipient));
}
private void sendReceipt(SignalServiceAddress remoteAddress, long messageId) throws IOException, UntrustedIdentityException {
SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.DELIVERY,
Collections.singletonList(messageId),
System.currentTimeMillis());
getMessageSender().sendReceipt(remoteAddress, getAccessFor(remoteAddress), receiptMessage);
}
@Override
public void sendMessage(String message, List<String> attachments, String recipient)
throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException {
@ -1500,6 +1509,15 @@ public class Manager implements Signal {
}
if (content.getDataMessage().isPresent()) {
SignalServiceDataMessage message = content.getDataMessage().get();
if (content.isNeedsReceipt()) {
try {
sendReceipt(sender, message.getTimestamp());
} catch (IOException | UntrustedIdentityException e) {
e.printStackTrace();
}
}
handleSignalServiceDataMessage(message, false, sender, account.getSelfAddress(), ignoreAttachments);
}
if (content.getSyncMessage().isPresent()) {