mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Don't attach contact ID to RemoteTransportPropertiesUpdatedEvent.
This commit is contained in:
@@ -39,8 +39,6 @@ import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.GROUP_KEY_CONTACT_ID;
|
||||
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.GROUP_KEY_CONTACT_IDS_STORED;
|
||||
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.GROUP_KEY_DISCOVERED;
|
||||
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MSG_KEY_LOCAL;
|
||||
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MSG_KEY_TRANSPORT_ID;
|
||||
@@ -80,10 +78,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
|
||||
@Override
|
||||
public void onDatabaseOpened(Transaction txn) throws DbException {
|
||||
if (db.containsGroup(txn, localGroup.getId())) {
|
||||
storeContactIdsForContactGroups(txn);
|
||||
return;
|
||||
}
|
||||
if (db.containsGroup(txn, localGroup.getId())) return;
|
||||
db.addGroup(txn, localGroup);
|
||||
// Set things up for any pre-existing contacts
|
||||
for (Contact c : db.getContacts(txn)) addingContact(txn, c);
|
||||
@@ -98,8 +93,6 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
Visibility client = clientVersioningManager.getClientVisibility(txn,
|
||||
c.getId(), CLIENT_ID, MAJOR_VERSION);
|
||||
db.setGroupVisibility(txn, c.getId(), g.getId(), client);
|
||||
// Attach the contact ID to the group
|
||||
storeContactId(txn, c, g);
|
||||
// Copy the latest local properties into the group
|
||||
Map<TransportId, TransportProperties> local = getLocalProperties(txn);
|
||||
for (Entry<TransportId, TransportProperties> e : local.entrySet()) {
|
||||
@@ -141,8 +134,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ContactId c = getContactId(txn, m.getGroupId());
|
||||
txn.attach(new RemoteTransportPropertiesUpdatedEvent(c, t));
|
||||
txn.attach(new RemoteTransportPropertiesUpdatedEvent(t));
|
||||
} catch (FormatException e) {
|
||||
throw new InvalidMessageException(e);
|
||||
}
|
||||
@@ -268,40 +260,6 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
}
|
||||
}
|
||||
|
||||
private void storeContactIdsForContactGroups(Transaction txn)
|
||||
throws DbException {
|
||||
try {
|
||||
BdfDictionary meta = clientHelper.getGroupMetadataAsDictionary(txn,
|
||||
localGroup.getId());
|
||||
if (meta.containsKey(GROUP_KEY_CONTACT_IDS_STORED)) return;
|
||||
for (Contact c : db.getContacts(txn)) {
|
||||
storeContactId(txn, c, getContactGroup(c));
|
||||
}
|
||||
meta.put(GROUP_KEY_CONTACT_IDS_STORED, true);
|
||||
clientHelper.mergeGroupMetadata(txn, localGroup.getId(), meta);
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void storeContactId(Transaction txn, Contact c, Group contactGroup)
|
||||
throws DbException {
|
||||
BdfDictionary meta = new BdfDictionary();
|
||||
meta.put(GROUP_KEY_CONTACT_ID, c.getId().getInt());
|
||||
try {
|
||||
clientHelper.mergeGroupMetadata(txn, contactGroup.getId(), meta);
|
||||
} catch (FormatException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ContactId getContactId(Transaction txn, GroupId contactGroupId)
|
||||
throws DbException, FormatException {
|
||||
BdfDictionary meta =
|
||||
clientHelper.getGroupMetadataAsDictionary(txn, contactGroupId);
|
||||
return new ContactId(meta.getLong(GROUP_KEY_CONTACT_ID).intValue());
|
||||
}
|
||||
|
||||
private TransportProperties getRemoteProperties(Transaction txn, Contact c,
|
||||
TransportId t) throws DbException {
|
||||
Group g = getContactGroup(c);
|
||||
|
||||
Reference in New Issue
Block a user