mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Only use conversation timestamp for messages that will be visible in conversation.
This commit is contained in:
@@ -20,6 +20,7 @@ import org.briarproject.bramble.api.properties.TransportProperties;
|
|||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.Message;
|
import org.briarproject.bramble.api.sync.Message;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||||
import org.briarproject.briar.api.client.MessageTracker;
|
import org.briarproject.briar.api.client.MessageTracker;
|
||||||
@@ -62,6 +63,7 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
protected final ClientVersioningManager clientVersioningManager;
|
protected final ClientVersioningManager clientVersioningManager;
|
||||||
protected final AutoDeleteManager autoDeleteManager;
|
protected final AutoDeleteManager autoDeleteManager;
|
||||||
protected final ConversationManager conversationManager;
|
protected final ConversationManager conversationManager;
|
||||||
|
protected final Clock clock;
|
||||||
|
|
||||||
AbstractProtocolEngine(
|
AbstractProtocolEngine(
|
||||||
DatabaseComponent db,
|
DatabaseComponent db,
|
||||||
@@ -75,7 +77,8 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
MessageEncoder messageEncoder,
|
MessageEncoder messageEncoder,
|
||||||
ClientVersioningManager clientVersioningManager,
|
ClientVersioningManager clientVersioningManager,
|
||||||
AutoDeleteManager autoDeleteManager,
|
AutoDeleteManager autoDeleteManager,
|
||||||
ConversationManager conversationManager) {
|
ConversationManager conversationManager,
|
||||||
|
Clock clock) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.clientHelper = clientHelper;
|
this.clientHelper = clientHelper;
|
||||||
this.contactManager = contactManager;
|
this.contactManager = contactManager;
|
||||||
@@ -88,6 +91,7 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
this.clientVersioningManager = clientVersioningManager;
|
this.clientVersioningManager = clientVersioningManager;
|
||||||
this.autoDeleteManager = autoDeleteManager;
|
this.autoDeleteManager = autoDeleteManager;
|
||||||
this.conversationManager = conversationManager;
|
this.conversationManager = conversationManager;
|
||||||
|
this.clock = clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message sendRequestMessage(Transaction txn, PeerSession s,
|
Message sendRequestMessage(Transaction txn, PeerSession s,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.properties.TransportProperties;
|
|||||||
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
||||||
import org.briarproject.bramble.api.sync.Message;
|
import org.briarproject.bramble.api.sync.Message;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.transport.KeyManager;
|
import org.briarproject.bramble.api.transport.KeyManager;
|
||||||
import org.briarproject.bramble.api.transport.KeySetId;
|
import org.briarproject.bramble.api.transport.KeySetId;
|
||||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||||
@@ -83,11 +84,12 @@ class IntroduceeProtocolEngine
|
|||||||
TransportPropertyManager transportPropertyManager,
|
TransportPropertyManager transportPropertyManager,
|
||||||
ClientVersioningManager clientVersioningManager,
|
ClientVersioningManager clientVersioningManager,
|
||||||
AutoDeleteManager autoDeleteManager,
|
AutoDeleteManager autoDeleteManager,
|
||||||
ConversationManager conversationManager) {
|
ConversationManager conversationManager,
|
||||||
|
Clock clock) {
|
||||||
super(db, clientHelper, contactManager, contactGroupFactory,
|
super(db, clientHelper, contactManager, contactGroupFactory,
|
||||||
messageTracker, identityManager, authorManager, messageParser,
|
messageTracker, identityManager, authorManager, messageParser,
|
||||||
messageEncoder, clientVersioningManager, autoDeleteManager,
|
messageEncoder, clientVersioningManager, autoDeleteManager,
|
||||||
conversationManager);
|
conversationManager, clock);
|
||||||
this.crypto = crypto;
|
this.crypto = crypto;
|
||||||
this.keyManager = keyManager;
|
this.keyManager = keyManager;
|
||||||
this.transportPropertyManager = transportPropertyManager;
|
this.transportPropertyManager = transportPropertyManager;
|
||||||
@@ -287,8 +289,8 @@ class IntroduceeProtocolEngine
|
|||||||
Map<TransportId, TransportProperties> transportProperties =
|
Map<TransportId, TransportProperties> transportProperties =
|
||||||
transportPropertyManager.getLocalProperties(txn);
|
transportPropertyManager.getLocalProperties(txn);
|
||||||
|
|
||||||
// Send a ACCEPT message
|
// Send an ACCEPT message
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForVisibleMessage(txn, s);
|
||||||
Message sent = sendAcceptMessage(txn, s, localTimestamp, publicKey,
|
Message sent = sendAcceptMessage(txn, s, localTimestamp, publicKey,
|
||||||
localTimestamp, transportProperties, true);
|
localTimestamp, transportProperties, true);
|
||||||
// Track the message
|
// Track the message
|
||||||
@@ -318,7 +320,7 @@ class IntroduceeProtocolEngine
|
|||||||
markRequestsUnavailableToAnswer(txn, s);
|
markRequestsUnavailableToAnswer(txn, s);
|
||||||
|
|
||||||
// Send a DECLINE message
|
// Send a DECLINE message
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForVisibleMessage(txn, s);
|
||||||
Message sent = sendDeclineMessage(txn, s, localTimestamp, true);
|
Message sent = sendDeclineMessage(txn, s, localTimestamp, true);
|
||||||
|
|
||||||
// Track the message
|
// Track the message
|
||||||
@@ -416,7 +418,7 @@ class IntroduceeProtocolEngine
|
|||||||
return abort(txn, s);
|
return abort(txn, s);
|
||||||
}
|
}
|
||||||
if (s.getState() != AWAIT_AUTH) throw new AssertionError();
|
if (s.getState() != AWAIT_AUTH) throw new AssertionError();
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForInvisibleMessage(s);
|
||||||
Message sent = sendAuthMessage(txn, s, localTimestamp, mac, signature);
|
Message sent = sendAuthMessage(txn, s, localTimestamp, mac, signature);
|
||||||
return IntroduceeSession.addLocalAuth(s, AWAIT_AUTH, sent, masterKey,
|
return IntroduceeSession.addLocalAuth(s, AWAIT_AUTH, sent, masterKey,
|
||||||
aliceMacKey, bobMacKey);
|
aliceMacKey, bobMacKey);
|
||||||
@@ -466,7 +468,7 @@ class IntroduceeProtocolEngine
|
|||||||
|
|
||||||
// send ACTIVATE message with a MAC
|
// send ACTIVATE message with a MAC
|
||||||
byte[] mac = crypto.activateMac(s);
|
byte[] mac = crypto.activateMac(s);
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForInvisibleMessage(s);
|
||||||
Message sent = sendActivateMessage(txn, s, localTimestamp, mac);
|
Message sent = sendActivateMessage(txn, s, localTimestamp, mac);
|
||||||
|
|
||||||
// Move to AWAIT_ACTIVATE state and clear key material from session
|
// Move to AWAIT_ACTIVATE state and clear key material from session
|
||||||
@@ -518,7 +520,7 @@ class IntroduceeProtocolEngine
|
|||||||
markRequestsUnavailableToAnswer(txn, s);
|
markRequestsUnavailableToAnswer(txn, s);
|
||||||
|
|
||||||
// Send an ABORT message
|
// Send an ABORT message
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForInvisibleMessage(s);
|
||||||
Message sent = sendAbortMessage(txn, s, localTimestamp);
|
Message sent = sendAbortMessage(txn, s, localTimestamp);
|
||||||
|
|
||||||
// Broadcast abort event for testing
|
// Broadcast abort event for testing
|
||||||
@@ -535,17 +537,33 @@ class IntroduceeProtocolEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a timestamp for an outgoing message, which is later than the
|
* Returns a timestamp for a visible outgoing message. The timestamp is
|
||||||
* timestamp of any message sent or received so far in the conversation
|
* later than the timestamp of any message sent or received so far in the
|
||||||
* or the session.
|
* conversation, and later than the {@link
|
||||||
|
* #getSessionTimestamp(IntroduceeSession) session timestamp}.
|
||||||
*/
|
*/
|
||||||
private long getLocalTimestamp(Transaction txn, IntroduceeSession s)
|
private long getTimestampForVisibleMessage(Transaction txn,
|
||||||
throws DbException {
|
IntroduceeSession s) throws DbException {
|
||||||
long conversationTimestamp =
|
long conversationTimestamp =
|
||||||
getTimestampForOutgoingMessage(txn, s.getContactGroupId());
|
getTimestampForOutgoingMessage(txn, s.getContactGroupId());
|
||||||
long sessionTimestamp =
|
return max(conversationTimestamp, getSessionTimestamp(s) + 1);
|
||||||
max(s.getLocalTimestamp(), s.getRequestTimestamp()) + 1;
|
}
|
||||||
return max(conversationTimestamp, sessionTimestamp);
|
|
||||||
|
/**
|
||||||
|
* Returns a timestamp for an invisible outgoing message. The timestamp is
|
||||||
|
* later than the {@link #getSessionTimestamp(IntroduceeSession) session
|
||||||
|
* timestamp}.
|
||||||
|
*/
|
||||||
|
private long getTimestampForInvisibleMessage(IntroduceeSession s) {
|
||||||
|
return max(clock.currentTimeMillis(), getSessionTimestamp(s) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest timestamp of any message sent so far in the session,
|
||||||
|
* and any request message received so far in the session.
|
||||||
|
*/
|
||||||
|
private long getSessionTimestamp(IntroduceeSession s) {
|
||||||
|
return max(s.getLocalTimestamp(), s.getRequestTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSessionId(Transaction txn, MessageId m, SessionId sessionId)
|
private void addSessionId(Transaction txn, MessageId m, SessionId sessionId)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.Message;
|
import org.briarproject.bramble.api.sync.Message;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||||
import org.briarproject.briar.api.client.MessageTracker;
|
import org.briarproject.briar.api.client.MessageTracker;
|
||||||
@@ -57,11 +58,12 @@ class IntroducerProtocolEngine
|
|||||||
MessageEncoder messageEncoder,
|
MessageEncoder messageEncoder,
|
||||||
ClientVersioningManager clientVersioningManager,
|
ClientVersioningManager clientVersioningManager,
|
||||||
AutoDeleteManager autoDeleteManager,
|
AutoDeleteManager autoDeleteManager,
|
||||||
ConversationManager conversationManager) {
|
ConversationManager conversationManager,
|
||||||
|
Clock clock) {
|
||||||
super(db, clientHelper, contactManager, contactGroupFactory,
|
super(db, clientHelper, contactManager, contactGroupFactory,
|
||||||
messageTracker, identityManager, authorManager, messageParser,
|
messageTracker, identityManager, authorManager, messageParser,
|
||||||
messageEncoder, clientVersioningManager, autoDeleteManager,
|
messageEncoder, clientVersioningManager, autoDeleteManager,
|
||||||
conversationManager);
|
conversationManager, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -219,8 +221,10 @@ class IntroducerProtocolEngine
|
|||||||
private IntroducerSession onLocalRequest(Transaction txn,
|
private IntroducerSession onLocalRequest(Transaction txn,
|
||||||
IntroducerSession s, @Nullable String text) throws DbException {
|
IntroducerSession s, @Nullable String text) throws DbException {
|
||||||
// Send REQUEST messages
|
// Send REQUEST messages
|
||||||
long timestampA = getLocalTimestamp(txn, s, s.getIntroduceeA());
|
long timestampA =
|
||||||
long timestampB = getLocalTimestamp(txn, s, s.getIntroduceeB());
|
getTimestampForVisibleMessage(txn, s, s.getIntroduceeA());
|
||||||
|
long timestampB =
|
||||||
|
getTimestampForVisibleMessage(txn, s, s.getIntroduceeB());
|
||||||
long localTimestamp = max(timestampA, timestampB);
|
long localTimestamp = max(timestampA, timestampB);
|
||||||
Message sentA = sendRequestMessage(txn, s.getIntroduceeA(),
|
Message sentA = sendRequestMessage(txn, s.getIntroduceeA(),
|
||||||
localTimestamp, s.getIntroduceeB().author, text);
|
localTimestamp, s.getIntroduceeB().author, text);
|
||||||
@@ -261,7 +265,8 @@ class IntroducerProtocolEngine
|
|||||||
|
|
||||||
// Forward ACCEPT message
|
// Forward ACCEPT message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
// The message will be visible to the introducee
|
||||||
|
long localTimestamp = getTimestampForVisibleMessage(txn, s, i);
|
||||||
Message sent = sendAcceptMessage(txn, i, localTimestamp,
|
Message sent = sendAcceptMessage(txn, i, localTimestamp,
|
||||||
m.getEphemeralPublicKey(), m.getAcceptTimestamp(),
|
m.getEphemeralPublicKey(), m.getAcceptTimestamp(),
|
||||||
m.getTransportProperties(), false);
|
m.getTransportProperties(), false);
|
||||||
@@ -321,7 +326,8 @@ class IntroducerProtocolEngine
|
|||||||
|
|
||||||
// Forward ACCEPT message
|
// Forward ACCEPT message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
// The message will be visible to the introducee
|
||||||
|
long localTimestamp = getTimestampForVisibleMessage(txn, s, i);
|
||||||
Message sent = sendAcceptMessage(txn, i, localTimestamp,
|
Message sent = sendAcceptMessage(txn, i, localTimestamp,
|
||||||
m.getEphemeralPublicKey(), m.getAcceptTimestamp(),
|
m.getEphemeralPublicKey(), m.getAcceptTimestamp(),
|
||||||
m.getTransportProperties(), false);
|
m.getTransportProperties(), false);
|
||||||
@@ -373,7 +379,8 @@ class IntroducerProtocolEngine
|
|||||||
|
|
||||||
// Forward DECLINE message
|
// Forward DECLINE message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
// The message will be visible to the introducee
|
||||||
|
long localTimestamp = getTimestampForVisibleMessage(txn, s, i);
|
||||||
Message sent = sendDeclineMessage(txn, i, localTimestamp, false);
|
Message sent = sendDeclineMessage(txn, i, localTimestamp, false);
|
||||||
|
|
||||||
// Create the next state
|
// Create the next state
|
||||||
@@ -425,7 +432,8 @@ class IntroducerProtocolEngine
|
|||||||
|
|
||||||
// Forward DECLINE message
|
// Forward DECLINE message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
// The message will be visible to the introducee
|
||||||
|
long localTimestamp = getTimestampForVisibleMessage(txn, s, i);
|
||||||
Message sent = sendDeclineMessage(txn, i, localTimestamp, false);
|
Message sent = sendDeclineMessage(txn, i, localTimestamp, false);
|
||||||
|
|
||||||
Introducee introduceeA, introduceeB;
|
Introducee introduceeA, introduceeB;
|
||||||
@@ -466,7 +474,7 @@ class IntroducerProtocolEngine
|
|||||||
|
|
||||||
// Forward AUTH message
|
// Forward AUTH message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
long localTimestamp = getTimestampForInvisibleMessage(s, i);
|
||||||
Message sent = sendAuthMessage(txn, i, localTimestamp, m.getMac(),
|
Message sent = sendAuthMessage(txn, i, localTimestamp, m.getMac(),
|
||||||
m.getSignature());
|
m.getSignature());
|
||||||
|
|
||||||
@@ -502,7 +510,7 @@ class IntroducerProtocolEngine
|
|||||||
|
|
||||||
// Forward ACTIVATE message
|
// Forward ACTIVATE message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
long localTimestamp = getTimestampForInvisibleMessage(s, i);
|
||||||
Message sent = sendActivateMessage(txn, i, localTimestamp, m.getMac());
|
Message sent = sendActivateMessage(txn, i, localTimestamp, m.getMac());
|
||||||
|
|
||||||
// Move to the next state
|
// Move to the next state
|
||||||
@@ -525,7 +533,7 @@ class IntroducerProtocolEngine
|
|||||||
IntroducerSession s, AbortMessage m) throws DbException {
|
IntroducerSession s, AbortMessage m) throws DbException {
|
||||||
// Forward ABORT message
|
// Forward ABORT message
|
||||||
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
Introducee i = getOtherIntroducee(s, m.getGroupId());
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, i);
|
long localTimestamp = getTimestampForInvisibleMessage(s, i);
|
||||||
Message sent = sendAbortMessage(txn, i, localTimestamp);
|
Message sent = sendAbortMessage(txn, i, localTimestamp);
|
||||||
|
|
||||||
// Broadcast abort event for testing
|
// Broadcast abort event for testing
|
||||||
@@ -550,7 +558,8 @@ class IntroducerProtocolEngine
|
|||||||
txn.attach(new IntroductionAbortedEvent(s.getSessionId()));
|
txn.attach(new IntroductionAbortedEvent(s.getSessionId()));
|
||||||
|
|
||||||
// Send an ABORT message to the remaining introducee
|
// Send an ABORT message to the remaining introducee
|
||||||
long localTimestamp = getLocalTimestamp(txn, s, remainingIntroducee);
|
long localTimestamp =
|
||||||
|
getTimestampForInvisibleMessage(s, remainingIntroducee);
|
||||||
Message sent =
|
Message sent =
|
||||||
sendAbortMessage(txn, remainingIntroducee, localTimestamp);
|
sendAbortMessage(txn, remainingIntroducee, localTimestamp);
|
||||||
// Reset the session back to initial state
|
// Reset the session back to initial state
|
||||||
@@ -577,9 +586,11 @@ class IntroducerProtocolEngine
|
|||||||
txn.attach(new IntroductionAbortedEvent(s.getSessionId()));
|
txn.attach(new IntroductionAbortedEvent(s.getSessionId()));
|
||||||
|
|
||||||
// Send an ABORT message to both introducees
|
// Send an ABORT message to both introducees
|
||||||
long timestampA = getLocalTimestamp(txn, s, s.getIntroduceeA());
|
long timestampA =
|
||||||
|
getTimestampForInvisibleMessage(s, s.getIntroduceeA());
|
||||||
Message sentA = sendAbortMessage(txn, s.getIntroduceeA(), timestampA);
|
Message sentA = sendAbortMessage(txn, s.getIntroduceeA(), timestampA);
|
||||||
long timestampB = getLocalTimestamp(txn, s, s.getIntroduceeB());
|
long timestampB =
|
||||||
|
getTimestampForInvisibleMessage(s, s.getIntroduceeB());
|
||||||
Message sentB = sendAbortMessage(txn, s.getIntroduceeB(), timestampB);
|
Message sentB = sendAbortMessage(txn, s.getIntroduceeB(), timestampB);
|
||||||
// Reset the session back to initial state
|
// Reset the session back to initial state
|
||||||
Introducee introduceeA = new Introducee(s.getIntroduceeA(), sentA);
|
Introducee introduceeA = new Introducee(s.getIntroduceeA(), sentA);
|
||||||
@@ -610,16 +621,32 @@ class IntroducerProtocolEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a timestamp for an outgoing message, which is later than the
|
* Returns a timestamp for a visible outgoing message. The timestamp is
|
||||||
* timestamp of any message sent or received so far in the conversation
|
* later than the timestamp of any message sent or received so far in the
|
||||||
* or the session.
|
* conversation, and later than the {@link
|
||||||
|
* #getSessionTimestamp(IntroducerSession, PeerSession) session timestamp}.
|
||||||
*/
|
*/
|
||||||
private long getLocalTimestamp(Transaction txn, IntroducerSession s,
|
private long getTimestampForVisibleMessage(Transaction txn,
|
||||||
PeerSession p) throws DbException {
|
IntroducerSession s, PeerSession p) throws DbException {
|
||||||
long conversationTimestamp =
|
long conversationTimestamp =
|
||||||
getTimestampForOutgoingMessage(txn, p.getContactGroupId());
|
getTimestampForOutgoingMessage(txn, p.getContactGroupId());
|
||||||
long sessionTimestamp =
|
return max(conversationTimestamp, getSessionTimestamp(s, p) + 1);
|
||||||
max(p.getLocalTimestamp(), s.getRequestTimestamp()) + 1;
|
}
|
||||||
return max(conversationTimestamp, sessionTimestamp);
|
|
||||||
|
/**
|
||||||
|
* Returns a timestamp for an invisible outgoing message. The timestamp is
|
||||||
|
* later than the {@link #getSessionTimestamp(IntroducerSession, PeerSession)
|
||||||
|
* session timestamp}.
|
||||||
|
*/
|
||||||
|
private long getTimestampForInvisibleMessage(IntroducerSession s,
|
||||||
|
PeerSession p) {
|
||||||
|
return max(clock.currentTimeMillis(), getSessionTimestamp(s, p) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest timestamp of any message sent so far in the session.
|
||||||
|
*/
|
||||||
|
private long getSessionTimestamp(IntroducerSession s, PeerSession p) {
|
||||||
|
return max(p.getLocalTimestamp(), s.getRequestTimestamp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,9 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
Message sendJoinMessage(Transaction txn, S s, boolean visibleInUi)
|
Message sendJoinMessage(Transaction txn, S s, boolean visibleInUi)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
Message m;
|
Message m;
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = visibleInUi
|
||||||
|
? getTimestampForVisibleMessage(txn, s)
|
||||||
|
: getTimestampForInvisibleMessage(s);
|
||||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
if (contactSupportsAutoDeletion(txn, c)) {
|
if (contactSupportsAutoDeletion(txn, c)) {
|
||||||
// Set auto-delete timer if manually accepting an invitation
|
// Set auto-delete timer if manually accepting an invitation
|
||||||
@@ -171,7 +173,9 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
Message sendLeaveMessage(Transaction txn, S s, boolean visibleInUi)
|
Message sendLeaveMessage(Transaction txn, S s, boolean visibleInUi)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
Message m;
|
Message m;
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = visibleInUi
|
||||||
|
? getTimestampForVisibleMessage(txn, s)
|
||||||
|
: getTimestampForInvisibleMessage(s);
|
||||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
if (contactSupportsAutoDeletion(txn, c)) {
|
if (contactSupportsAutoDeletion(txn, c)) {
|
||||||
// Set auto-delete timer if manually accepting an invitation
|
// Set auto-delete timer if manually accepting an invitation
|
||||||
@@ -196,7 +200,7 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
Message sendAbortMessage(Transaction txn, S session) throws DbException {
|
Message sendAbortMessage(Transaction txn, S session) throws DbException {
|
||||||
Message m = messageEncoder.encodeAbortMessage(
|
Message m = messageEncoder.encodeAbortMessage(
|
||||||
session.getContactGroupId(), session.getPrivateGroupId(),
|
session.getContactGroupId(), session.getPrivateGroupId(),
|
||||||
getLocalTimestamp(txn, session));
|
getTimestampForInvisibleMessage(session));
|
||||||
sendMessage(txn, m, ABORT, session.getPrivateGroupId(), false,
|
sendMessage(txn, m, ABORT, session.getPrivateGroupId(), false,
|
||||||
NO_AUTO_DELETE_TIMER);
|
NO_AUTO_DELETE_TIMER);
|
||||||
return m;
|
return m;
|
||||||
@@ -263,17 +267,33 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a timestamp for an outgoing message, which is later than the
|
* Returns a timestamp for a visible outgoing message. The timestamp is
|
||||||
* timestamp of any message sent or received so far in the conversation
|
* later than the timestamp of any message sent or received so far in the
|
||||||
* or the session.
|
* conversation, and later than the {@link #getSessionTimestamp(Session)
|
||||||
|
* session timestamp}.
|
||||||
*/
|
*/
|
||||||
long getLocalTimestamp(Transaction txn, S s) throws DbException {
|
long getTimestampForVisibleMessage(Transaction txn, S s)
|
||||||
|
throws DbException {
|
||||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
long conversationTimestamp =
|
long conversationTimestamp =
|
||||||
conversationManager.getTimestampForOutgoingMessage(txn, c);
|
conversationManager.getTimestampForOutgoingMessage(txn, c);
|
||||||
long sessionTimestamp =
|
return max(conversationTimestamp, getSessionTimestamp(s) + 1);
|
||||||
max(s.getLocalTimestamp(), s.getInviteTimestamp()) + 1;
|
}
|
||||||
return max(conversationTimestamp, sessionTimestamp);
|
|
||||||
|
/**
|
||||||
|
* Returns a timestamp for an invisible outgoing message. The timestamp is
|
||||||
|
* later than the {@link #getSessionTimestamp(Session) session timestamp}.
|
||||||
|
*/
|
||||||
|
long getTimestampForInvisibleMessage(S s) {
|
||||||
|
return max(clock.currentTimeMillis(), getSessionTimestamp(s) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest timestamp of any message sent so far in the session,
|
||||||
|
* and any invite message sent or received so far in the session.
|
||||||
|
*/
|
||||||
|
private long getSessionTimestamp(S s) {
|
||||||
|
return max(s.getLocalTimestamp(), s.getInviteTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(Transaction txn, Message m, MessageType type,
|
private void sendMessage(Transaction txn, Message m, MessageType type,
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
|
|||||||
// Track the message
|
// Track the message
|
||||||
messageTracker.trackOutgoingMessage(txn, sent);
|
messageTracker.trackOutgoingMessage(txn, sent);
|
||||||
// Move to the INVITED state
|
// Move to the INVITED state
|
||||||
long localTimestamp = max(timestamp, getLocalTimestamp(txn, s));
|
long localTimestamp =
|
||||||
|
max(timestamp, getTimestampForVisibleMessage(txn, s));
|
||||||
return new CreatorSession(s.getContactGroupId(), s.getPrivateGroupId(),
|
return new CreatorSession(s.getContactGroupId(), s.getPrivateGroupId(),
|
||||||
sent.getId(), s.getLastRemoteMessageId(), localTimestamp,
|
sent.getId(), s.getLastRemoteMessageId(), localTimestamp,
|
||||||
timestamp, INVITED);
|
timestamp, INVITED);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.briarproject.bramble.api.db.Transaction;
|
|||||||
import org.briarproject.bramble.api.event.Event;
|
import org.briarproject.bramble.api.event.Event;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||||
import org.briarproject.briar.api.blog.Blog;
|
import org.briarproject.briar.api.blog.Blog;
|
||||||
@@ -42,11 +43,12 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
|||||||
MessageTracker messageTracker,
|
MessageTracker messageTracker,
|
||||||
AutoDeleteManager autoDeleteManager,
|
AutoDeleteManager autoDeleteManager,
|
||||||
ConversationManager conversationManager,
|
ConversationManager conversationManager,
|
||||||
|
Clock clock,
|
||||||
BlogManager blogManager,
|
BlogManager blogManager,
|
||||||
InvitationFactory<Blog, BlogInvitationResponse> invitationFactory) {
|
InvitationFactory<Blog, BlogInvitationResponse> invitationFactory) {
|
||||||
super(db, clientHelper, clientVersioningManager, messageEncoder,
|
super(db, clientHelper, clientVersioningManager, messageEncoder,
|
||||||
messageParser, messageTracker, autoDeleteManager,
|
messageParser, messageTracker, autoDeleteManager,
|
||||||
conversationManager, BlogSharingManager.CLIENT_ID,
|
conversationManager, clock, BlogSharingManager.CLIENT_ID,
|
||||||
BlogSharingManager.MAJOR_VERSION, BlogManager.CLIENT_ID,
|
BlogSharingManager.MAJOR_VERSION, BlogManager.CLIENT_ID,
|
||||||
BlogManager.MAJOR_VERSION);
|
BlogManager.MAJOR_VERSION);
|
||||||
this.blogManager = blogManager;
|
this.blogManager = blogManager;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.briarproject.bramble.api.db.Transaction;
|
|||||||
import org.briarproject.bramble.api.event.Event;
|
import org.briarproject.bramble.api.event.Event;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||||
import org.briarproject.briar.api.client.MessageTracker;
|
import org.briarproject.briar.api.client.MessageTracker;
|
||||||
@@ -42,11 +43,12 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
|||||||
MessageTracker messageTracker,
|
MessageTracker messageTracker,
|
||||||
AutoDeleteManager autoDeleteManager,
|
AutoDeleteManager autoDeleteManager,
|
||||||
ConversationManager conversationManager,
|
ConversationManager conversationManager,
|
||||||
|
Clock clock,
|
||||||
ForumManager forumManager,
|
ForumManager forumManager,
|
||||||
InvitationFactory<Forum, ForumInvitationResponse> invitationFactory) {
|
InvitationFactory<Forum, ForumInvitationResponse> invitationFactory) {
|
||||||
super(db, clientHelper, clientVersioningManager, messageEncoder,
|
super(db, clientHelper, clientVersioningManager, messageEncoder,
|
||||||
messageParser, messageTracker, autoDeleteManager,
|
messageParser, messageTracker, autoDeleteManager,
|
||||||
conversationManager, ForumSharingManager.CLIENT_ID,
|
conversationManager, clock, ForumSharingManager.CLIENT_ID,
|
||||||
ForumSharingManager.MAJOR_VERSION, ForumManager.CLIENT_ID,
|
ForumSharingManager.MAJOR_VERSION, ForumManager.CLIENT_ID,
|
||||||
ForumManager.MAJOR_VERSION);
|
ForumManager.MAJOR_VERSION);
|
||||||
this.forumManager = forumManager;
|
this.forumManager = forumManager;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.briarproject.bramble.api.sync.Group.Visibility;
|
|||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.Message;
|
import org.briarproject.bramble.api.sync.Message;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||||
import org.briarproject.briar.api.client.MessageTracker;
|
import org.briarproject.briar.api.client.MessageTracker;
|
||||||
@@ -60,6 +61,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
private final MessageTracker messageTracker;
|
private final MessageTracker messageTracker;
|
||||||
private final AutoDeleteManager autoDeleteManager;
|
private final AutoDeleteManager autoDeleteManager;
|
||||||
private final ConversationManager conversationManager;
|
private final ConversationManager conversationManager;
|
||||||
|
private final Clock clock;
|
||||||
private final ClientId sharingClientId, shareableClientId;
|
private final ClientId sharingClientId, shareableClientId;
|
||||||
private final int sharingClientMajorVersion, shareableClientMajorVersion;
|
private final int sharingClientMajorVersion, shareableClientMajorVersion;
|
||||||
|
|
||||||
@@ -72,6 +74,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
MessageTracker messageTracker,
|
MessageTracker messageTracker,
|
||||||
AutoDeleteManager autoDeleteManager,
|
AutoDeleteManager autoDeleteManager,
|
||||||
ConversationManager conversationManager,
|
ConversationManager conversationManager,
|
||||||
|
Clock clock,
|
||||||
ClientId sharingClientId,
|
ClientId sharingClientId,
|
||||||
int sharingClientMajorVersion,
|
int sharingClientMajorVersion,
|
||||||
ClientId shareableClientId,
|
ClientId shareableClientId,
|
||||||
@@ -84,6 +87,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
this.messageTracker = messageTracker;
|
this.messageTracker = messageTracker;
|
||||||
this.autoDeleteManager = autoDeleteManager;
|
this.autoDeleteManager = autoDeleteManager;
|
||||||
this.conversationManager = conversationManager;
|
this.conversationManager = conversationManager;
|
||||||
|
this.clock = clock;
|
||||||
this.sharingClientId = sharingClientId;
|
this.sharingClientId = sharingClientId;
|
||||||
this.sharingClientMajorVersion = sharingClientMajorVersion;
|
this.sharingClientMajorVersion = sharingClientMajorVersion;
|
||||||
this.shareableClientId = shareableClientId;
|
this.shareableClientId = shareableClientId;
|
||||||
@@ -134,8 +138,8 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e); // Invalid group descriptor
|
throw new DbException(e); // Invalid group descriptor
|
||||||
}
|
}
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
|
||||||
Message m;
|
Message m;
|
||||||
|
long localTimestamp = getTimestampForVisibleMessage(txn, s);
|
||||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
if (contactSupportsAutoDeletion(txn, c)) {
|
if (contactSupportsAutoDeletion(txn, c)) {
|
||||||
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
||||||
@@ -202,7 +206,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
private Message sendAcceptMessage(Transaction txn, Session s)
|
private Message sendAcceptMessage(Transaction txn, Session s)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
Message m;
|
Message m;
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForVisibleMessage(txn, s);
|
||||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
if (contactSupportsAutoDeletion(txn, c)) {
|
if (contactSupportsAutoDeletion(txn, c)) {
|
||||||
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
||||||
@@ -256,7 +260,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
private Message sendDeclineMessage(Transaction txn, Session s)
|
private Message sendDeclineMessage(Transaction txn, Session s)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
Message m;
|
Message m;
|
||||||
long localTimestamp = getLocalTimestamp(txn, s);
|
long localTimestamp = getTimestampForVisibleMessage(txn, s);
|
||||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
if (contactSupportsAutoDeletion(txn, c)) {
|
if (contactSupportsAutoDeletion(txn, c)) {
|
||||||
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
||||||
@@ -310,7 +314,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
|
|
||||||
private Message sendLeaveMessage(Transaction txn, Session session)
|
private Message sendLeaveMessage(Transaction txn, Session session)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
long localTimestamp = getLocalTimestamp(txn, session);
|
long localTimestamp = getTimestampForInvisibleMessage(session);
|
||||||
Message m = messageEncoder.encodeLeaveMessage(
|
Message m = messageEncoder.encodeLeaveMessage(
|
||||||
session.getContactGroupId(), session.getShareableId(),
|
session.getContactGroupId(), session.getShareableId(),
|
||||||
localTimestamp, session.getLastLocalMessageId());
|
localTimestamp, session.getLastLocalMessageId());
|
||||||
@@ -609,7 +613,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
|
|
||||||
private Message sendAbortMessage(Transaction txn, Session session)
|
private Message sendAbortMessage(Transaction txn, Session session)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
long localTimestamp = getLocalTimestamp(txn, session);
|
long localTimestamp = getTimestampForInvisibleMessage(session);
|
||||||
Message m = messageEncoder.encodeAbortMessage(
|
Message m = messageEncoder.encodeAbortMessage(
|
||||||
session.getContactGroupId(), session.getShareableId(),
|
session.getContactGroupId(), session.getShareableId(),
|
||||||
localTimestamp, session.getLastLocalMessageId());
|
localTimestamp, session.getLastLocalMessageId());
|
||||||
@@ -683,18 +687,33 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a timestamp for an outgoing message, which is later than the
|
* Returns a timestamp for a visible outgoing message. The timestamp is
|
||||||
* timestamp of any message sent or received so far in the conversation
|
* later than the timestamp of any message sent or received so far in the
|
||||||
* or the session.
|
* conversation, and later than the {@link #getSessionTimestamp(Session)
|
||||||
|
* session timestamp}.
|
||||||
*/
|
*/
|
||||||
private long getLocalTimestamp(Transaction txn, Session session)
|
private long getTimestampForVisibleMessage(Transaction txn, Session s)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
ContactId c = getContactId(txn, session.getContactGroupId());
|
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||||
long conversationTimestamp =
|
long conversationTimestamp =
|
||||||
conversationManager.getTimestampForOutgoingMessage(txn, c);
|
conversationManager.getTimestampForOutgoingMessage(txn, c);
|
||||||
long sessionTimestamp = max(session.getLocalTimestamp(),
|
return max(conversationTimestamp, getSessionTimestamp(s) + 1);
|
||||||
session.getInviteTimestamp()) + 1;
|
}
|
||||||
return max(conversationTimestamp, sessionTimestamp);
|
|
||||||
|
/**
|
||||||
|
* Returns a timestamp for an invisible outgoing message. The timestamp is
|
||||||
|
* later than the {@link #getSessionTimestamp(Session) session timestamp}.
|
||||||
|
*/
|
||||||
|
private long getTimestampForInvisibleMessage(Session s) {
|
||||||
|
return max(clock.currentTimeMillis(), getSessionTimestamp(s) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest timestamp of any message sent so far in the session,
|
||||||
|
* and any invite message sent or received so far in the session.
|
||||||
|
*/
|
||||||
|
private long getSessionTimestamp(Session s) {
|
||||||
|
return max(s.getLocalTimestamp(), s.getInviteTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContactId getContactId(Transaction txn, GroupId contactGroupId)
|
private ContactId getContactId(Transaction txn, GroupId contactGroupId)
|
||||||
|
|||||||
@@ -118,7 +118,14 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
|||||||
assertEquals(inviteTimestamp, s.getInviteTimestamp());
|
assertEquals(inviteTimestamp, s.getInviteTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
void expectGetLocalTimestamp(long time) throws Exception {
|
void expectGetTimestampForInvisibleMessage(long time) {
|
||||||
|
context.checking(new Expectations() {{
|
||||||
|
oneOf(clock).currentTimeMillis();
|
||||||
|
will(returnValue(time));
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
void expectGetTimestampForVisibleMessage(long time) throws Exception {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
||||||
will(returnValue(contactId));
|
will(returnValue(contactId));
|
||||||
@@ -129,7 +136,7 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expectSendInviteMessage(String text) throws Exception {
|
void expectSendInviteMessage(String text) throws Exception {
|
||||||
expectGetLocalTimestamp(messageTimestamp);
|
expectGetTimestampForVisibleMessage(messageTimestamp);
|
||||||
expectCheckWhetherContactSupportsAutoDeletion();
|
expectCheckWhetherContactSupportsAutoDeletion();
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(messageEncoder).encodeInviteMessage(contactGroupId,
|
oneOf(messageEncoder).encodeInviteMessage(contactGroupId,
|
||||||
@@ -143,7 +150,8 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
void expectSendJoinMessage(JoinMessage m, boolean visible)
|
void expectSendJoinMessage(JoinMessage m, boolean visible)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
expectGetLocalTimestamp(messageTimestamp);
|
if (visible) expectGetTimestampForVisibleMessage(messageTimestamp);
|
||||||
|
else expectGetTimestampForInvisibleMessage(messageTimestamp);
|
||||||
expectCheckWhetherContactSupportsAutoDeletion();
|
expectCheckWhetherContactSupportsAutoDeletion();
|
||||||
if (visible) expectGetAutoDeleteTimer();
|
if (visible) expectGetAutoDeleteTimer();
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
@@ -156,7 +164,8 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expectSendLeaveMessage(boolean visible) throws Exception {
|
void expectSendLeaveMessage(boolean visible) throws Exception {
|
||||||
expectGetLocalTimestamp(messageTimestamp);
|
if (visible) expectGetTimestampForVisibleMessage(messageTimestamp);
|
||||||
|
else expectGetTimestampForInvisibleMessage(messageTimestamp);
|
||||||
expectCheckWhetherContactSupportsAutoDeletion();
|
expectCheckWhetherContactSupportsAutoDeletion();
|
||||||
if (visible) expectGetAutoDeleteTimer();
|
if (visible) expectGetAutoDeleteTimer();
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
@@ -169,7 +178,7 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expectSendAbortMessage() throws Exception {
|
void expectSendAbortMessage() throws Exception {
|
||||||
expectGetLocalTimestamp(messageTimestamp);
|
expectGetTimestampForInvisibleMessage(messageTimestamp);
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(messageEncoder)
|
oneOf(messageEncoder)
|
||||||
.encodeAbortMessage(contactGroupId, privateGroupId,
|
.encodeAbortMessage(contactGroupId, privateGroupId,
|
||||||
|
|||||||
Reference in New Issue
Block a user