Only show Introduction Accept Information if success is still possible

This commit is contained in:
Torsten Grote
2018-04-28 11:27:43 -03:00
parent ebf73716bb
commit 1aec948f18
9 changed files with 43 additions and 10 deletions

View File

@@ -149,11 +149,12 @@ abstract class AbstractProtocolEngine<S extends Session>
throws DbException {
AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId();
Contact c = contactManager.getContact(txn, sender, localAuthorId);
boolean possible = s.getState().successPossible();
IntroductionResponse response =
new IntroductionResponse(s.getSessionId(), m.getMessageId(),
m.getGroupId(), s.getRole(), m.getTimestamp(), false,
false, false, false, otherAuthor.getName(),
m instanceof AcceptMessage);
m instanceof AcceptMessage, possible);
IntroductionResponseReceivedEvent e =
new IntroductionResponseReceivedEvent(c.getId(), response);
txn.attach(e);

View File

@@ -34,4 +34,10 @@ enum IntroduceeState implements State {
throw new FormatException();
}
@Override
public boolean successPossible() {
return this != START && this != LOCAL_DECLINED &&
this != REMOTE_DECLINED;
}
}

View File

@@ -34,4 +34,9 @@ enum IntroducerState implements State {
throw new FormatException();
}
@Override
public boolean successPossible() {
return this != START && this != A_DECLINED && this != B_DECLINED;
}
}

View File

@@ -470,6 +470,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
Role role = sessionParser.getRole(bdfSession);
SessionId sessionId;
Author author;
boolean successPossible;
if (role == INTRODUCER) {
IntroducerSession session =
sessionParser.parseIntroducerSession(bdfSession);
@@ -479,15 +480,18 @@ class IntroductionManagerImpl extends ConversationClientImpl
} else {
author = session.getIntroduceeA().author;
}
successPossible = session.getState().successPossible();
} else if (role == INTRODUCEE) {
IntroduceeSession session = sessionParser
.parseIntroduceeSession(contactGroupId, bdfSession);
sessionId = session.getSessionId();
author = session.getRemote().author;
successPossible = session.getState().successPossible();
} else throw new AssertionError();
return new IntroductionResponse(sessionId, m, contactGroupId,
role, meta.getTimestamp(), meta.isLocal(), status.isSent(),
status.isSeen(), meta.isRead(), author.getName(), accept);
status.isSeen(), meta.isRead(), author.getName(), accept,
successPossible);
}
private void removeSessionWithIntroducer(Transaction txn,

View File

@@ -4,4 +4,6 @@ interface State {
int getValue();
boolean successPossible();
}

View File

@@ -415,8 +415,8 @@ public class IntroductionIntegrationTest
eventWaiter.await(TIMEOUT, 1);
assertTrue(listener0.response2Received);
// Forward AUTH
sync0To1(1, true);
// Forward AUTH and response
sync0To1(2, true);
// Second AUTH and ACTIVATE and forward them
sync1To0(2, true);