mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Add method to get contact ids of existing custodians
This commit is contained in:
@@ -612,4 +612,30 @@ class SocialBackupManagerImpl extends ConversationClientImpl
|
||||
results.entrySet().iterator().next();
|
||||
return new Pair<>(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
public List<ContactId> getCustodianContactIds(Transaction txn) {
|
||||
ArrayList<ContactId> contactIds = new ArrayList<>();
|
||||
try {
|
||||
BackupMetadata b = getBackupMetadata(txn);
|
||||
if (b == null) throw new DbException();
|
||||
List<Author> custodians = b.getCustodians();
|
||||
for (Author custodian : custodians) {
|
||||
contactIds.add(authorToContactId(txn, custodian));
|
||||
}
|
||||
} catch (DbException ignored) {
|
||||
// Will return an empty list
|
||||
}
|
||||
return contactIds;
|
||||
}
|
||||
|
||||
private ContactId authorToContactId(Transaction txn, Author author)
|
||||
throws DbException {
|
||||
ArrayList<Contact> contacts =
|
||||
(ArrayList<Contact>) contactManager.getContacts(txn);
|
||||
for (Contact c : contacts) {
|
||||
if (c.getAuthor().equals(author)) return c.getId();
|
||||
}
|
||||
throw new DbException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user