Allow read-only transaction when not marking message as sent.

This commit is contained in:
akwizgran
2022-08-03 16:36:32 +01:00
parent 8657216345
commit 16fc4f4527
2 changed files with 5 additions and 1 deletions

View File

@@ -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.
* <p/>
* 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

View File

@@ -746,7 +746,9 @@ class DatabaseComponentImpl<T> 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();