Added a method for revealing a contact to a private group.

This commit is contained in:
akwizgran
2016-11-11 13:49:49 +00:00
parent 98cf6b5bba
commit 3a2205123f
2 changed files with 30 additions and 0 deletions

View File

@@ -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.

View File

@@ -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 {