diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/db/DatabaseComponent.java b/bramble-api/src/main/java/org/briarproject/bramble/api/db/DatabaseComponent.java index c28c07fe9..f68d666d6 100644 --- a/bramble-api/src/main/java/org/briarproject/bramble/api/db/DatabaseComponent.java +++ b/bramble-api/src/main/java/org/briarproject/bramble/api/db/DatabaseComponent.java @@ -492,6 +492,8 @@ public interface DatabaseComponent extends TransactionManager { * Returns the message with the given ID for transmission to the given * contact over a transport with the given maximum latency. Returns null * if the message is no longer visible to the contact. + *

+ * Read-only if {@code markAsSent} is false. * * @param markAsSent True if the message should be marked as sent. * If false it can be marked as sent by calling diff --git a/bramble-core/src/main/java/org/briarproject/bramble/db/DatabaseComponentImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/db/DatabaseComponentImpl.java index cfc20ecce..01c1497fe 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/db/DatabaseComponentImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/db/DatabaseComponentImpl.java @@ -746,7 +746,9 @@ class DatabaseComponentImpl implements DatabaseComponent { public Message getMessageToSend(Transaction transaction, ContactId c, MessageId m, long maxLatency, boolean markAsSent) throws DbException { - if (transaction.isReadOnly()) throw new IllegalArgumentException(); + if (markAsSent && transaction.isReadOnly()) { + throw new IllegalArgumentException(); + } T txn = unbox(transaction); if (!db.containsContact(txn, c)) throw new NoSuchContactException();