mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Added a method for revealing a contact to a private group.
This commit is contained in:
@@ -42,6 +42,12 @@ public interface GroupInvitationManager {
|
||||
void respondToInvitation(ContactId c, SessionId s, boolean accept)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Makes the user's relationship with the given contact visible to the
|
||||
* given private group.
|
||||
*/
|
||||
void revealRelationship(ContactId c, GroupId g) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all private group invitation messages related to the given
|
||||
* contact.
|
||||
|
||||
@@ -315,6 +315,30 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revealRelationship(ContactId c, GroupId g) throws DbException {
|
||||
Transaction txn = db.startTransaction(false);
|
||||
try {
|
||||
// Look up the session
|
||||
Contact contact = db.getContact(txn, c);
|
||||
GroupId contactGroupId = getContactGroup(contact).getId();
|
||||
StoredSession ss = getSession(txn, contactGroupId, getSessionId(g));
|
||||
if (ss == null) throw new IllegalArgumentException();
|
||||
// Parse the session
|
||||
PeerSession session = sessionParser
|
||||
.parsePeerSession(contactGroupId, ss.bdfSession);
|
||||
// Handle the join action
|
||||
session = peerEngine.onJoinAction(txn, session);
|
||||
// Store the updated session
|
||||
storeSession(txn, ss.storageId, session);
|
||||
db.commitTransaction(txn);
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
}
|
||||
|
||||
private <S extends Session> S handleAction(Transaction txn,
|
||||
LocalAction type, S session, ProtocolEngine<S> engine)
|
||||
throws DbException, FormatException {
|
||||
|
||||
Reference in New Issue
Block a user