From 593152e7cd960c1be95eae0ed29770e505ef50b5 Mon Sep 17 00:00:00 2001 From: Torsten Grote <t@grobox.de> Date: Thu, 17 Nov 2016 09:44:44 -0200 Subject: [PATCH] Do not track incoming positive introduction responses because they are not shown in the UI and are therefore not marked as read. This fixes the unread message count. --- .../IntroductionIntegrationTest.java | 16 ++++++++++++---- .../introduction/IntroductionManagerImpl.java | 6 ++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/briar-android-tests/src/test/java/org/briarproject/introduction/IntroductionIntegrationTest.java b/briar-android-tests/src/test/java/org/briarproject/introduction/IntroductionIntegrationTest.java index d3745f08b0..86ed51afb1 100644 --- a/briar-android-tests/src/test/java/org/briarproject/introduction/IntroductionIntegrationTest.java +++ b/briar-android-tests/src/test/java/org/briarproject/introduction/IntroductionIntegrationTest.java @@ -240,8 +240,8 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest { // sync forwarded responses to introducees deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1"); deliverMessage(sync0, contactId0, sync2, contactId2, "0 to 2"); - assertGroupCount(messageTracker1, g1.getId(), 3, 2); - assertGroupCount(messageTracker2, g2.getId(), 3, 2); + assertGroupCount(messageTracker1, g1.getId(), 2, 1); + assertGroupCount(messageTracker2, g2.getId(), 2, 1); // sync first ACK and its forward deliverMessage(sync1, contactId1, sync0, contactId0, "1 to 0"); @@ -276,8 +276,8 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest { assertDefaultUiMessages(); assertGroupCount(messageTracker0, g1.getId(), 2, 1); assertGroupCount(messageTracker0, g2.getId(), 2, 1); - assertGroupCount(messageTracker1, g1.getId(), 3, 2); - assertGroupCount(messageTracker2, g2.getId(), 3, 2); + assertGroupCount(messageTracker1, g1.getId(), 2, 1); + assertGroupCount(messageTracker2, g2.getId(), 2, 1); } finally { stopLifecycles(); } @@ -332,19 +332,27 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest { assertFalse(contactManager2 .contactExists(author1.getId(), author2.getId())); + Group g1 = introductionGroupFactory + .createIntroductionGroup(introducee1); + Group g2 = introductionGroupFactory + .createIntroductionGroup(introducee2); assertEquals(2, introductionManager0.getIntroductionMessages(contactId1) .size()); + assertGroupCount(messageTracker0, g1.getId(), 2, 1); assertEquals(2, introductionManager0.getIntroductionMessages(contactId2) .size()); + assertGroupCount(messageTracker0, g2.getId(), 2, 1); assertEquals(2, introductionManager1.getIntroductionMessages(contactId0) .size()); + assertGroupCount(messageTracker1, g1.getId(), 2, 1); // introducee2 should also have the decline response of introducee1 assertEquals(3, introductionManager2.getIntroductionMessages(contactId0) .size()); + assertGroupCount(messageTracker2, g2.getId(), 3, 2); } finally { stopLifecycles(); } diff --git a/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java b/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java index e3f7981a5d..8bdae86880 100644 --- a/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java +++ b/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java @@ -237,15 +237,17 @@ class IntroductionManagerImpl extends ConversationClientImpl try { if (role == ROLE_INTRODUCER) { introducerManager.incomingMessage(txn, state, message); + if (type == TYPE_RESPONSE) + messageTracker.trackIncomingMessage(txn, m); } else if (role == ROLE_INTRODUCEE) { introduceeManager.incomingMessage(txn, state, message); + if (type == TYPE_RESPONSE && !message.getBoolean(ACCEPT)) + messageTracker.trackIncomingMessage(txn, m); } else { if (LOG.isLoggable(WARNING)) LOG.warning("Unknown role '" + role + "'"); throw new DbException(); } - if (type == TYPE_RESPONSE) - messageTracker.trackIncomingMessage(txn, m); } catch (DbException e) { if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (role == ROLE_INTRODUCER) introducerManager.abort(txn, state); -- GitLab