mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
[core] Add method to ConversationClient that returns a set of MessageIds it is responsible for
This commit is contained in:
@@ -12,6 +12,7 @@ import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface ConversationManager {
|
||||
@@ -51,6 +52,13 @@ public interface ConversationManager {
|
||||
Collection<ConversationMessageHeader> getMessageHeaders(Transaction txn,
|
||||
ContactId contactId) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all conversation {@link MessageId}s for the given contact
|
||||
* this client is responsible for.
|
||||
*/
|
||||
Set<MessageId> getMessageIds(Transaction txn, ContactId contactId)
|
||||
throws DbException;
|
||||
|
||||
GroupCount getGroupCount(Transaction txn, ContactId c)
|
||||
throws DbException;
|
||||
|
||||
|
||||
@@ -660,7 +660,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
return allDeleted;
|
||||
}
|
||||
|
||||
private Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
@Override
|
||||
public Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
GroupId g = getContactGroup(db.getContact(txn, c)).getId();
|
||||
BdfDictionary query = messageParser.getMessagesVisibleInUiQuery();
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.contact.ContactManager.ContactHook;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfEntry;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.data.MetadataParser;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
@@ -47,6 +48,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
@@ -363,6 +365,21 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
GroupId g = getContactGroup(db.getContact(txn, c)).getId();
|
||||
BdfDictionary query = BdfDictionary.of(
|
||||
new BdfEntry(MSG_KEY_MSG_TYPE, PRIVATE_MESSAGE));
|
||||
try {
|
||||
Map<MessageId, BdfDictionary> results =
|
||||
clientHelper.getMessageMetadataAsDictionary(txn, g, query);
|
||||
return results.keySet();
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(MessageId m) throws DbException {
|
||||
try {
|
||||
|
||||
@@ -729,7 +729,8 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
return allDeleted;
|
||||
}
|
||||
|
||||
private Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
@Override
|
||||
public Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
GroupId g = getContactGroup(db.getContact(txn, c)).getId();
|
||||
BdfDictionary query = messageParser.getMessagesVisibleInUiQuery();
|
||||
|
||||
@@ -629,7 +629,8 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
return allDeleted;
|
||||
}
|
||||
|
||||
private Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
@Override
|
||||
public Set<MessageId> getMessageIds(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
GroupId g = getContactGroup(db.getContact(txn, c)).getId();
|
||||
BdfDictionary query = messageParser.getMessagesVisibleInUiQuery();
|
||||
|
||||
Reference in New Issue
Block a user