mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 06:39:54 +01:00
Reset retransmission times when contact's mailbox props change
This commit is contained in:
@@ -158,6 +158,12 @@ class MailboxPropertyManagerImpl implements MailboxPropertyManager,
|
|||||||
BdfList body = clientHelper.getMessageAsList(txn, m.getId());
|
BdfList body = clientHelper.getMessageAsList(txn, m.getId());
|
||||||
MailboxPropertiesUpdate p = parseProperties(body);
|
MailboxPropertiesUpdate p = parseProperties(body);
|
||||||
txn.attach(new RemoteMailboxPropertiesUpdateEvent(c, p));
|
txn.attach(new RemoteMailboxPropertiesUpdateEvent(c, p));
|
||||||
|
// Reset message retransmission timers for the contact. Avoiding
|
||||||
|
// messages getting stranded:
|
||||||
|
// - on our mailbox, if they now have a mailbox but didn't before
|
||||||
|
// - on the contact's old mailbox, if they removed their mailbox
|
||||||
|
// - on the contact's old mailbox, if they replaced their mailbox
|
||||||
|
db.resetUnackedMessagesToSend(txn, c);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new InvalidMessageException(e);
|
throw new InvalidMessageException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,6 +281,7 @@ public class MailboxPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
public void testDoesNotDeleteAnythingWhenFirstUpdateIsDelivered()
|
public void testDoesNotDeleteAnythingWhenFirstUpdateIsDelivered()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Transaction txn = new Transaction(null, false);
|
Transaction txn = new Transaction(null, false);
|
||||||
|
Contact contact = getContact();
|
||||||
GroupId contactGroupId = new GroupId(getRandomId());
|
GroupId contactGroupId = new GroupId(getRandomId());
|
||||||
Message message = getMessage(contactGroupId);
|
Message message = getMessage(contactGroupId);
|
||||||
BdfList body = BdfList.of(1, propsDict);
|
BdfList body = BdfList.of(1, propsDict);
|
||||||
@@ -304,11 +305,13 @@ public class MailboxPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
contactGroupId);
|
contactGroupId);
|
||||||
will(returnValue(messageMetadata));
|
will(returnValue(messageMetadata));
|
||||||
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
||||||
|
will(returnValue(contact.getId()));
|
||||||
oneOf(clientHelper).getMessageAsList(txn, message.getId());
|
oneOf(clientHelper).getMessageAsList(txn, message.getId());
|
||||||
will(returnValue(body));
|
will(returnValue(body));
|
||||||
oneOf(clientHelper).parseAndValidateMailboxPropertiesUpdate(
|
oneOf(clientHelper).parseAndValidateMailboxPropertiesUpdate(
|
||||||
propsDict);
|
propsDict);
|
||||||
will(returnValue(props));
|
will(returnValue(props));
|
||||||
|
oneOf(db).resetUnackedMessagesToSend(txn, contact.getId());
|
||||||
}});
|
}});
|
||||||
|
|
||||||
MailboxPropertyManagerImpl t = createInstance();
|
MailboxPropertyManagerImpl t = createInstance();
|
||||||
@@ -321,6 +324,7 @@ public class MailboxPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
public void testDeletesOlderUpdateWhenUpdateIsDelivered()
|
public void testDeletesOlderUpdateWhenUpdateIsDelivered()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Transaction txn = new Transaction(null, false);
|
Transaction txn = new Transaction(null, false);
|
||||||
|
Contact contact = getContact();
|
||||||
GroupId contactGroupId = new GroupId(getRandomId());
|
GroupId contactGroupId = new GroupId(getRandomId());
|
||||||
Message message = getMessage(contactGroupId);
|
Message message = getMessage(contactGroupId);
|
||||||
BdfList body = BdfList.of(1, propsDict);
|
BdfList body = BdfList.of(1, propsDict);
|
||||||
@@ -352,11 +356,13 @@ public class MailboxPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
oneOf(db).deleteMessage(txn, updateId);
|
oneOf(db).deleteMessage(txn, updateId);
|
||||||
oneOf(db).deleteMessageMetadata(txn, updateId);
|
oneOf(db).deleteMessageMetadata(txn, updateId);
|
||||||
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
||||||
|
will(returnValue(contact.getId()));
|
||||||
oneOf(clientHelper).getMessageAsList(txn, message.getId());
|
oneOf(clientHelper).getMessageAsList(txn, message.getId());
|
||||||
will(returnValue(body));
|
will(returnValue(body));
|
||||||
oneOf(clientHelper).parseAndValidateMailboxPropertiesUpdate(
|
oneOf(clientHelper).parseAndValidateMailboxPropertiesUpdate(
|
||||||
propsDict);
|
propsDict);
|
||||||
will(returnValue(props));
|
will(returnValue(props));
|
||||||
|
oneOf(db).resetUnackedMessagesToSend(txn, contact.getId());
|
||||||
}});
|
}});
|
||||||
|
|
||||||
MailboxPropertyManagerImpl t = createInstance();
|
MailboxPropertyManagerImpl t = createInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user