mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Merge branch '1632-allow-resharing-shareable' into 'master'
Allow sharer to re-share a shareable again after leaving Closes #1632 See merge request briar/briar!1169
This commit is contained in:
@@ -496,9 +496,11 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
|||||||
txn.attach(e);
|
txn.attach(e);
|
||||||
// Stop sharing the shareable with the contact
|
// Stop sharing the shareable with the contact
|
||||||
setShareableVisibility(txn, s, INVISIBLE);
|
setShareableVisibility(txn, s, INVISIBLE);
|
||||||
|
// Send a LEAVE message, so the other party doesn't hang in LOCAL_LEFT
|
||||||
|
Message sent = sendLeaveMessage(txn, s);
|
||||||
// Move to the next state
|
// Move to the next state
|
||||||
return new Session(START, s.getContactGroupId(), s.getShareableId(),
|
return new Session(START, s.getContactGroupId(), s.getShareableId(),
|
||||||
s.getLastLocalMessageId(), m.getId(), s.getLocalTimestamp(),
|
sent.getId(), m.getId(), sent.getTimestamp(),
|
||||||
s.getInviteTimestamp());
|
s.getInviteTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,23 @@ public class ForumSharingIntegrationTest
|
|||||||
// forum can be shared again
|
// forum can be shared again
|
||||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||||
assertTrue(forumSharingManager0.canBeShared(forum.getId(), c1));
|
assertTrue(forumSharingManager0.canBeShared(forum.getId(), c1));
|
||||||
|
|
||||||
|
// sharer un-subscribes from forum
|
||||||
|
forumManager0.removeForum(forum);
|
||||||
|
|
||||||
|
// send a new invitation again after re-adding the forum
|
||||||
|
db0.transaction(false, txn -> forumManager0.addForum(txn, forum));
|
||||||
|
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||||
|
null, clock.currentTimeMillis());
|
||||||
|
|
||||||
|
// reset listener state for new request
|
||||||
|
listener1.requestReceived = false;
|
||||||
|
listener1.requestContactId = null;
|
||||||
|
|
||||||
|
// sync only 1 request message to make sure there wasn't an abort
|
||||||
|
sync0To1(1, true);
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertRequestReceived(listener1, contactId0From1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -288,9 +305,16 @@ public class ForumSharingIntegrationTest
|
|||||||
// forum can be shared again by sharer
|
// forum can be shared again by sharer
|
||||||
assertTrue(forumSharingManager0
|
assertTrue(forumSharingManager0
|
||||||
.canBeShared(forum.getId(), contact1From0));
|
.canBeShared(forum.getId(), contact1From0));
|
||||||
// invitee that left can not share again
|
// invitee that left can not yet share again
|
||||||
assertFalse(forumSharingManager1
|
assertFalse(forumSharingManager1
|
||||||
.canBeShared(forum.getId(), contact0From1));
|
.canBeShared(forum.getId(), contact0From1));
|
||||||
|
|
||||||
|
// sharer responds with leave message
|
||||||
|
sync0To1(1, true);
|
||||||
|
|
||||||
|
// invitee that left can now share again
|
||||||
|
assertTrue(forumSharingManager1
|
||||||
|
.canBeShared(forum.getId(), contact0From1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -344,8 +368,31 @@ public class ForumSharingIntegrationTest
|
|||||||
// sharer no longer gets forum shared by invitee
|
// sharer no longer gets forum shared by invitee
|
||||||
assertFalse(forumSharingManager1.getSharedWith(forum.getId())
|
assertFalse(forumSharingManager1.getSharedWith(forum.getId())
|
||||||
.contains(contact0));
|
.contains(contact0));
|
||||||
// forum can be shared again
|
// forum can be re-shared by invitee now
|
||||||
assertTrue(forumSharingManager1.canBeShared(forum.getId(), c0));
|
assertTrue(forumSharingManager1.canBeShared(forum.getId(), c0));
|
||||||
|
|
||||||
|
// invitee responds with LEAVE message
|
||||||
|
sync1To0(1, true);
|
||||||
|
|
||||||
|
// sharer can share forum again as well now
|
||||||
|
assertTrue(forumSharingManager0.canBeShared(forum.getId(), c1));
|
||||||
|
|
||||||
|
// invitee also un-subscribes forum without effect
|
||||||
|
forumManager1.removeForum(forum);
|
||||||
|
|
||||||
|
// send a new invitation again after re-adding the forum
|
||||||
|
db0.transaction(false, txn -> forumManager0.addForum(txn, forum));
|
||||||
|
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||||
|
null, clock.currentTimeMillis());
|
||||||
|
|
||||||
|
// reset listener state for new request
|
||||||
|
listener1.requestReceived = false;
|
||||||
|
listener1.requestContactId = null;
|
||||||
|
|
||||||
|
// sync request message
|
||||||
|
sync0To1(1, true);
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertRequestReceived(listener1, contactId0From1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -856,10 +903,13 @@ public class ForumSharingIntegrationTest
|
|||||||
assertEquals(0, getMessages0From1().size());
|
assertEquals(0, getMessages0From1().size());
|
||||||
assertGroupCount(messageTracker1, g0From1, 0, 0);
|
assertGroupCount(messageTracker1, g0From1, 0, 0);
|
||||||
|
|
||||||
// both leave forum and send LEAVE message
|
// sharer leaves forum and sends LEAVE message
|
||||||
forumManager0.removeForum(forum);
|
forumManager0.removeForum(forum);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
|
// invitee responds with LEAVE message
|
||||||
|
sync1To0(1, true);
|
||||||
|
|
||||||
// sending invitation is possible again
|
// sending invitation is possible again
|
||||||
forumSharingManager1.sendInvitation(forum.getId(), contactId0From1,
|
forumSharingManager1.sendInvitation(forum.getId(), contactId0From1,
|
||||||
null, clock.currentTimeMillis());
|
null, clock.currentTimeMillis());
|
||||||
|
|||||||
Reference in New Issue
Block a user