mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Merge branch 'use-contact-id-as-conversation-id' into 'master'
Use contact ID rather than messaging group ID to identify conversation We originally used the private messaging group ID to identify the private conversation, but now that the conversation includes messages from multiple clients it's more appropriate to use the contact ID. This refactoring isn't urgent - I've had the branch lying around for a while, but I'm putting it up for review because #734 will touch some of the same code. See merge request !386
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
package org.briarproject.messaging;
|
||||
|
||||
import org.briarproject.api.clients.ContactGroupFactory;
|
||||
import org.briarproject.api.clients.MessageTracker.GroupCount;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.messaging.ConversationManager;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
@@ -19,14 +15,11 @@ import javax.inject.Inject;
|
||||
class ConversationManagerImpl implements ConversationManager {
|
||||
|
||||
private final DatabaseComponent db;
|
||||
private final ContactGroupFactory contactGroupFactory;
|
||||
private final Set<ConversationClient> clients;
|
||||
|
||||
@Inject
|
||||
ConversationManagerImpl(DatabaseComponent db,
|
||||
ContactGroupFactory contactGroupFactory) {
|
||||
ConversationManagerImpl(DatabaseComponent db) {
|
||||
this.db = db;
|
||||
this.contactGroupFactory = contactGroupFactory;
|
||||
clients = new CopyOnWriteArraySet<ConversationClient>();
|
||||
}
|
||||
|
||||
@@ -38,23 +31,6 @@ class ConversationManagerImpl implements ConversationManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupId getConversationId(ContactId contactId) throws DbException {
|
||||
// TODO we should probably transition this to its own group
|
||||
// and/or work with the ContactId in the UI instead
|
||||
Contact contact;
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
contact = db.getContact(txn, contactId);
|
||||
db.commitTransaction(txn);
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
Group group = contactGroupFactory
|
||||
.createContactGroup(MessagingManagerImpl.CLIENT_ID, contact);
|
||||
return group.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupCount getGroupCount(ContactId contactId)
|
||||
throws DbException {
|
||||
|
||||
Reference in New Issue
Block a user