Implement viewedReceipt

commit cd29144e81
Merge: 14532be f884175
Author: AsamK <asamk@gmx.de>
Date:   Sat Oct 30 12:46:59 2021 +0200

    Merge branch 'master' into dbus_sendviewed

commit 14532befde
Author: John Freed <okgithub@johnfreed.com>
Date:   Thu Oct 7 08:24:00 2021 +0200

    update deliveryReceipt to conform

commit a9a6edaf3f
Author: John Freed <okgithub@johnfreed.com>
Date:   Thu Oct 7 07:40:20 2021 +0200

    implement viewedReceipt

    for Dbus and Json -- note that this changes the JsonReceiptMessage
    structure

    update documentation

Closes #764
This commit is contained in:
John Freed 2021-10-30 12:53:33 +02:00 committed by AsamK
parent f884175748
commit cb70209c60
4 changed files with 27 additions and 3 deletions

View file

@ -37,6 +37,10 @@ public interface Signal extends DBusInterface {
String recipient, List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity;
void sendViewedReceipt(
String recipient, List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity;
long sendRemoteDeleteMessage(
long targetSentTimestamp, String recipient
) throws Error.Failure, Error.InvalidNumber;

View file

@ -278,6 +278,19 @@ public class DbusSignalImpl implements Signal {
}
}
@Override
public void sendViewedReceipt(
final String recipient, final List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity {
try {
m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
} catch (IOException e) {
throw new Error.Failure(e.getMessage());
} catch (UntrustedIdentityException e) {
throw new Error.UntrustedIdentity(e.getMessage());
}
}
@Override
public void sendContacts() {
try {

View file

@ -4,17 +4,18 @@ import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage
import java.util.List;
record JsonReceiptMessage(long when, boolean isDelivery, boolean isRead, List<Long> timestamps) {
record JsonReceiptMessage(long when, boolean isDelivery, boolean isRead, boolean isViewed, List<Long> timestamps) {
static JsonReceiptMessage from(SignalServiceReceiptMessage receiptMessage) {
final var when = receiptMessage.getWhen();
final var isDelivery = receiptMessage.isDeliveryReceipt();
final var isRead = receiptMessage.isReadReceipt();
final var isViewed = receiptMessage.isViewedReceipt();
final var timestamps = receiptMessage.getTimestamps();
return new JsonReceiptMessage(when, isDelivery, isRead, timestamps);
return new JsonReceiptMessage(when, isDelivery, isRead, isViewed, timestamps);
}
static JsonReceiptMessage deliveryReceipt(final long when, final List<Long> timestamps) {
return new JsonReceiptMessage(when, true, false, timestamps);
return new JsonReceiptMessage(when, true, false, false, timestamps);
}
}