mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
add transactional versions to delete message functions
This commit is contained in:
@@ -96,12 +96,24 @@ public interface ConversationManager {
|
|||||||
*/
|
*/
|
||||||
DeletionResult deleteAllMessages(ContactId c) throws DbException;
|
DeletionResult deleteAllMessages(ContactId c) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all messages exchanged with the given contact.
|
||||||
|
*/
|
||||||
|
DeletionResult deleteAllMessages(Transaction txn, ContactId c)
|
||||||
|
throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the given set of messages associated with the given contact.
|
* Deletes the given set of messages associated with the given contact.
|
||||||
*/
|
*/
|
||||||
DeletionResult deleteMessages(ContactId c, Collection<MessageId> messageIds)
|
DeletionResult deleteMessages(ContactId c, Collection<MessageId> messageIds)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the given set of messages associated with the given contact.
|
||||||
|
*/
|
||||||
|
DeletionResult deleteMessages(Transaction txn, ContactId c,
|
||||||
|
Collection<MessageId> messageIds) throws DbException;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
interface ConversationClient {
|
interface ConversationClient {
|
||||||
|
|
||||||
|
|||||||
@@ -146,27 +146,37 @@ class ConversationManagerImpl implements ConversationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeletionResult deleteAllMessages(ContactId c) throws DbException {
|
public DeletionResult deleteAllMessages(ContactId c) throws DbException {
|
||||||
return db.transactionWithResult(false, txn -> {
|
return db.transactionWithResult(false, txn ->
|
||||||
DeletionResult result = new DeletionResult();
|
deleteAllMessages(txn, c));
|
||||||
for (ConversationClient client : clients) {
|
}
|
||||||
result.addDeletionResult(client.deleteAllMessages(txn, c));
|
|
||||||
}
|
@Override
|
||||||
return result;
|
public DeletionResult deleteAllMessages(Transaction txn, ContactId c)
|
||||||
});
|
throws DbException {
|
||||||
|
DeletionResult result = new DeletionResult();
|
||||||
|
for (ConversationClient client : clients) {
|
||||||
|
result.addDeletionResult(client.deleteAllMessages(txn, c));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeletionResult deleteMessages(ContactId c,
|
public DeletionResult deleteMessages(ContactId c,
|
||||||
Collection<MessageId> toDelete) throws DbException {
|
Collection<MessageId> toDelete) throws DbException {
|
||||||
return db.transactionWithResult(false, txn -> {
|
return db.transactionWithResult(false, txn ->
|
||||||
DeletionResult result = new DeletionResult();
|
deleteMessages(txn, c, toDelete));
|
||||||
for (ConversationClient client : clients) {
|
}
|
||||||
Set<MessageId> idSet = client.getMessageIds(txn, c);
|
|
||||||
idSet.retainAll(toDelete);
|
@Override
|
||||||
result.addDeletionResult(client.deleteMessages(txn, c, idSet));
|
public DeletionResult deleteMessages(Transaction txn, ContactId c,
|
||||||
}
|
Collection<MessageId> toDelete) throws DbException {
|
||||||
return result;
|
DeletionResult result = new DeletionResult();
|
||||||
});
|
for (ConversationClient client : clients) {
|
||||||
|
Set<MessageId> idSet = client.getMessageIds(txn, c);
|
||||||
|
idSet.retainAll(toDelete);
|
||||||
|
result.addDeletionResult(client.deleteMessages(txn, c, idSet));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user