mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 14:49:53 +01:00
Don't auto-delete invisible forwarded responses on sender side
They will be visible for the recipient, so send with timer
This commit is contained in:
@@ -127,15 +127,17 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
Message m;
|
Message m;
|
||||||
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 =
|
||||||
timestamp);
|
autoDeleteManager.getAutoDeleteTimer(txn, c, timestamp);
|
||||||
m = messageEncoder.encodeAcceptMessage(s.getContactGroupId(),
|
m = messageEncoder.encodeAcceptMessage(s.getContactGroupId(),
|
||||||
timestamp, s.getLastLocalMessageId(), s.getSessionId(),
|
timestamp, s.getLastLocalMessageId(), s.getSessionId(),
|
||||||
ephemeralPublicKey, acceptTimestamp, transportProperties,
|
ephemeralPublicKey, acceptTimestamp, transportProperties,
|
||||||
timer);
|
timer);
|
||||||
sendMessage(txn, ACCEPT, s.getSessionId(), m, visible, timer);
|
sendMessage(txn, ACCEPT, s.getSessionId(), m, visible, timer);
|
||||||
// Set the auto-delete timer duration on the message
|
// Set the auto-delete timer duration on the message
|
||||||
if (timer != NO_AUTO_DELETE_TIMER) {
|
// only if it is visible in our conversation.
|
||||||
|
// It will be sent with timer, so it destructs at introducee.
|
||||||
|
if (visible && timer != NO_AUTO_DELETE_TIMER) {
|
||||||
db.setCleanupTimerDuration(txn, m.getId(), timer);
|
db.setCleanupTimerDuration(txn, m.getId(), timer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -154,15 +156,17 @@ abstract class AbstractProtocolEngine<S extends Session<?>>
|
|||||||
Message m;
|
Message m;
|
||||||
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 =
|
||||||
timestamp);
|
autoDeleteManager.getAutoDeleteTimer(txn, c, timestamp);
|
||||||
m = messageEncoder.encodeDeclineMessage(s.getContactGroupId(),
|
m = messageEncoder.encodeDeclineMessage(s.getContactGroupId(),
|
||||||
timestamp, s.getLastLocalMessageId(), s.getSessionId(),
|
timestamp, s.getLastLocalMessageId(), s.getSessionId(),
|
||||||
timer);
|
timer);
|
||||||
sendMessage(txn, DECLINE, s.getSessionId(), m, visible, timer,
|
sendMessage(txn, DECLINE, s.getSessionId(), m, visible, timer,
|
||||||
isAutoDecline);
|
isAutoDecline);
|
||||||
// Set the auto-delete timer duration on the local message
|
// Set the auto-delete timer duration on the local message
|
||||||
if (timer != NO_AUTO_DELETE_TIMER) {
|
// only if it is visible in our conversation.
|
||||||
|
// It will be sent with timer, so it destructs at introducee.
|
||||||
|
if (visible && timer != NO_AUTO_DELETE_TIMER) {
|
||||||
db.setCleanupTimerDuration(txn, m.getId(), timer);
|
db.setCleanupTimerDuration(txn, m.getId(), timer);
|
||||||
}
|
}
|
||||||
if (isAutoDecline) {
|
if (isAutoDecline) {
|
||||||
|
|||||||
@@ -303,20 +303,24 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go through two full cycles of introducing two contacts with
|
* The forwarded accepts are not visible in the conversation
|
||||||
* self-destructing messages enabled, lettings them both introducees expire
|
* and should not expire.
|
||||||
* their introductions, thereby auto-declining it.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testTwoIntroductionCycles() throws Exception {
|
public void testInvisibleAcceptForwards() throws Exception {
|
||||||
// FIRST CYCLE
|
testInvisibleForwards(true);
|
||||||
introduceAndAutoDecline();
|
|
||||||
|
|
||||||
// SECOND CYCLE
|
|
||||||
introduceAndAutoDecline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void introduceAndAutoDecline() throws Exception {
|
/**
|
||||||
|
* The forwarded declines are not visible in the conversation
|
||||||
|
* and should not expire.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testInvisibleDeclineForwards() throws Exception {
|
||||||
|
testInvisibleForwards(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testInvisibleForwards(boolean accept) throws Exception {
|
||||||
// send introduction
|
// send introduction
|
||||||
makeIntroduction(true, true);
|
makeIntroduction(true, true);
|
||||||
markMessagesRead(c1, contact0From1);
|
markMessagesRead(c1, contact0From1);
|
||||||
@@ -328,39 +332,49 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest {
|
|||||||
ack2To0(1);
|
ack2To0(1);
|
||||||
waitForEvents(c0);
|
waitForEvents(c0);
|
||||||
|
|
||||||
// time travel on all devices, destroying the introductions at 0 and
|
// respond to the introduction
|
||||||
// making 1 and 2 auto-decline
|
respondToMostRecentIntroduction(c1, contactId0From1, accept);
|
||||||
|
respondToMostRecentIntroduction(c2, contactId0From2, accept);
|
||||||
|
|
||||||
|
// time travel on all devices, destroying the introductions
|
||||||
timeTravel(c0);
|
timeTravel(c0);
|
||||||
timeTravel(c1);
|
timeTravel(c1);
|
||||||
timeTravel(c2);
|
timeTravel(c2);
|
||||||
assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0);
|
assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0);
|
||||||
|
|
||||||
// sync the auto-decline messages to 0
|
// sync the response messages to 0
|
||||||
sync1To0(1, true);
|
sync1To0(1, true);
|
||||||
sync2To0(1, true);
|
sync2To0(1, true);
|
||||||
waitForEvents(c0);
|
waitForEvents(c0);
|
||||||
assertGroupCounts(1, 1, 1, 1, 1, 0, 1, 0);
|
assertGroupCounts(1, 1, 1, 1, 1, 0, 1, 0);
|
||||||
|
|
||||||
// mark declines read on 0, starting the timer there and let them expire
|
// mark responses read on 0, starting the timer there and let them expire
|
||||||
markMessagesRead(c0, contact1From0);
|
markMessagesRead(c0, contact1From0);
|
||||||
markMessagesRead(c0, contact2From0);
|
markMessagesRead(c0, contact2From0);
|
||||||
timeTravel(c0);
|
timeTravel(c0);
|
||||||
assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0);
|
assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0);
|
||||||
|
|
||||||
// sync responses to 1 and 2
|
// sync forwarded responses to 1 and 2
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
sync0To2(1, true);
|
sync0To2(1, true);
|
||||||
waitForEvents(c1);
|
waitForEvents(c1);
|
||||||
waitForEvents(c2);
|
waitForEvents(c2);
|
||||||
|
|
||||||
// ack the responses to 0 to clear the ack counts for subsequent cycles,
|
// ack the forwarded responses to 0
|
||||||
// also starts the timer for the responses at 1 and 2
|
// also starts the timer for the responses at 1 and 2
|
||||||
ack1To0(1);
|
if (accept) {
|
||||||
ack2To0(1);
|
// when accepting, another message is sent together with the ACK
|
||||||
|
sync1To0(1, true);
|
||||||
|
sync2To0(1, true);
|
||||||
|
} else {
|
||||||
|
ack1To0(1);
|
||||||
|
ack2To0(1);
|
||||||
|
}
|
||||||
waitForEvents(c0);
|
waitForEvents(c0);
|
||||||
assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0);
|
assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0);
|
||||||
|
|
||||||
// let timers for responses expire
|
// let timers for responses and their forwards expire
|
||||||
|
timeTravel(c0);
|
||||||
timeTravel(c1);
|
timeTravel(c1);
|
||||||
timeTravel(c2);
|
timeTravel(c2);
|
||||||
assertGroupCounts(0, 0, 0, 0, 0, 0, 0, 0);
|
assertGroupCounts(0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user