mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Move introduction role into IntroductionResponse
This commit is contained in:
@@ -20,7 +20,6 @@ import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.introduction.Introduction;
|
||||
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionResponseReceivedEvent;
|
||||
|
||||
@@ -148,14 +147,13 @@ abstract class AbstractProtocolEngine<S extends Session>
|
||||
void broadcastIntroductionResponseReceivedEvent(Transaction txn, Session s,
|
||||
AuthorId sender, Author otherAuthor, AbstractIntroductionMessage m)
|
||||
throws DbException {
|
||||
Introduction introduction = new Introduction(otherAuthor, s.getRole());
|
||||
AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId();
|
||||
Contact c = contactManager.getContact(txn, sender, localAuthorId);
|
||||
IntroductionResponse response =
|
||||
new IntroductionResponse(m.getMessageId(), m.getGroupId(),
|
||||
m.getTimestamp(), false, false, false, false,
|
||||
s.getSessionId(), introduction,
|
||||
m instanceof AcceptMessage);
|
||||
s.getSessionId(), otherAuthor,
|
||||
m instanceof AcceptMessage, s.getRole());
|
||||
IntroductionResponseReceivedEvent e =
|
||||
new IntroductionResponseReceivedEvent(response, c.getId());
|
||||
txn.attach(e);
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.briarproject.bramble.api.transport.KeySetId;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.ProtocolStateException;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.introduction.Introduction;
|
||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionAbortedEvent;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionRequestReceivedEvent;
|
||||
@@ -255,11 +254,9 @@ class IntroduceeProtocolEngine
|
||||
localAuthor.getId());
|
||||
boolean contactExists = contactManager
|
||||
.contactExists(txn, m.getAuthor().getId(), localAuthor.getId());
|
||||
Introduction introduction =
|
||||
new Introduction(m.getAuthor(), s.getRole());
|
||||
IntroductionRequest request = new IntroductionRequest(m.getMessageId(),
|
||||
m.getGroupId(), m.getTimestamp(), false, false, false, false,
|
||||
s.getSessionId(), introduction, m.getMessage(), false,
|
||||
s.getSessionId(), m.getAuthor(), m.getMessage(), false,
|
||||
contactExists);
|
||||
IntroductionRequestReceivedEvent e =
|
||||
new IntroductionRequestReceivedEvent(request, c.getId());
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager.ClientVersioningHook;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.introduction.Introduction;
|
||||
import org.briarproject.briar.api.introduction.IntroductionManager;
|
||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
||||
@@ -467,10 +466,9 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
boolean contactExists = contactManager
|
||||
.contactExists(txn, rm.getAuthor().getId(),
|
||||
localAuthor.getId());
|
||||
Introduction introduction = new Introduction(author, role);
|
||||
return new IntroductionRequest(m, contactGroupId, meta.getTimestamp(),
|
||||
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(),
|
||||
sessionId, introduction, message, !meta.isAvailableToAnswer(),
|
||||
sessionId, author, message, !meta.isAvailableToAnswer(),
|
||||
contactExists);
|
||||
}
|
||||
|
||||
@@ -495,10 +493,9 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
sessionId = session.getSessionId();
|
||||
author = session.getRemote().author;
|
||||
} else throw new AssertionError();
|
||||
Introduction introduction = new Introduction(author, role);
|
||||
return new IntroductionResponse(m, contactGroupId, meta.getTimestamp(),
|
||||
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(),
|
||||
sessionId, introduction, accept);
|
||||
sessionId, author, accept, role);
|
||||
}
|
||||
|
||||
private void removeSessionWithIntroducer(Transaction txn,
|
||||
|
||||
@@ -24,16 +24,14 @@ import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.TestDatabaseModule;
|
||||
import org.briarproject.briar.api.client.ProtocolStateException;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.introduction.Introduction;
|
||||
import org.briarproject.briar.api.introduction.IntroductionManager;
|
||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionAbortedEvent;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionRequestReceivedEvent;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionResponseReceivedEvent;
|
||||
import org.briarproject.briar.api.introduction.event.IntroductionSucceededEvent;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.briar.api.messaging.PrivateRequest;
|
||||
import org.briarproject.briar.api.messaging.PrivateResponse;
|
||||
import org.briarproject.briar.test.BriarIntegrationTest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -1148,7 +1146,7 @@ public class IntroductionIntegrationTest
|
||||
protected volatile Event latestEvent;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
PrivateResponse<Introduction> getResponse() {
|
||||
IntroductionResponse getResponse() {
|
||||
assertTrue(
|
||||
latestEvent instanceof IntroductionResponseReceivedEvent);
|
||||
return ((IntroductionResponseReceivedEvent) latestEvent)
|
||||
@@ -1180,7 +1178,7 @@ public class IntroductionIntegrationTest
|
||||
IntroductionRequestReceivedEvent introEvent =
|
||||
((IntroductionRequestReceivedEvent) e);
|
||||
requestReceived = true;
|
||||
PrivateRequest<Introduction> ir = introEvent.getMessageHeader();
|
||||
IntroductionRequest ir = introEvent.getMessageHeader();
|
||||
ContactId contactId = introEvent.getContactId();
|
||||
sessionId = ir.getSessionId();
|
||||
long time = clock.currentTimeMillis();
|
||||
@@ -1217,7 +1215,7 @@ public class IntroductionIntegrationTest
|
||||
}
|
||||
}
|
||||
|
||||
private PrivateRequest<Introduction> getRequest() {
|
||||
private IntroductionRequest getRequest() {
|
||||
assertTrue(
|
||||
latestEvent instanceof IntroductionRequestReceivedEvent);
|
||||
return ((IntroductionRequestReceivedEvent) latestEvent)
|
||||
|
||||
Reference in New Issue
Block a user