mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Move lookup of latest conversation timestamp to core for blog and forum sharing.
This commit is contained in:
@@ -10,11 +10,9 @@ import org.briarproject.bramble.api.db.NoSuchGroupException;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.briar.android.contactselection.ContactSelectorControllerImpl;
|
||||
import org.briarproject.briar.android.controller.handler.ExceptionHandler;
|
||||
import org.briarproject.briar.api.blog.BlogSharingManager;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.identity.AuthorManager;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -26,6 +24,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
|
||||
@Immutable
|
||||
@@ -34,22 +33,17 @@ class ShareBlogControllerImpl extends ContactSelectorControllerImpl
|
||||
implements ShareBlogController {
|
||||
|
||||
private final static Logger LOG =
|
||||
Logger.getLogger(ShareBlogControllerImpl.class.getName());
|
||||
getLogger(ShareBlogControllerImpl.class.getName());
|
||||
|
||||
private final ConversationManager conversationManager;
|
||||
private final BlogSharingManager blogSharingManager;
|
||||
private final Clock clock;
|
||||
|
||||
@Inject
|
||||
ShareBlogControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||
LifecycleManager lifecycleManager, ContactManager contactManager,
|
||||
AuthorManager authorManager,
|
||||
ConversationManager conversationManager,
|
||||
BlogSharingManager blogSharingManager, Clock clock) {
|
||||
BlogSharingManager blogSharingManager) {
|
||||
super(dbExecutor, lifecycleManager, contactManager, authorManager);
|
||||
this.conversationManager = conversationManager;
|
||||
this.blogSharingManager = blogSharingManager;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,10 +58,7 @@ class ShareBlogControllerImpl extends ContactSelectorControllerImpl
|
||||
try {
|
||||
for (ContactId c : contacts) {
|
||||
try {
|
||||
long time = Math.max(clock.currentTimeMillis(),
|
||||
conversationManager.getGroupCount(c)
|
||||
.getLatestMsgTime() + 1);
|
||||
blogSharingManager.sendInvitation(g, c, text, time);
|
||||
blogSharingManager.sendInvitation(g, c, text);
|
||||
} catch (NoSuchContactException | NoSuchGroupException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,8 @@ import org.briarproject.bramble.api.db.NoSuchGroupException;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.briar.android.contactselection.ContactSelectorControllerImpl;
|
||||
import org.briarproject.briar.android.controller.handler.ExceptionHandler;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.forum.ForumSharingManager;
|
||||
import org.briarproject.briar.api.identity.AuthorManager;
|
||||
|
||||
@@ -26,6 +24,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
|
||||
@Immutable
|
||||
@@ -34,22 +33,17 @@ class ShareForumControllerImpl extends ContactSelectorControllerImpl
|
||||
implements ShareForumController {
|
||||
|
||||
private final static Logger LOG =
|
||||
Logger.getLogger(ShareForumControllerImpl.class.getName());
|
||||
getLogger(ShareForumControllerImpl.class.getName());
|
||||
|
||||
private final ConversationManager conversationManager;
|
||||
private final ForumSharingManager forumSharingManager;
|
||||
private final Clock clock;
|
||||
|
||||
@Inject
|
||||
ShareForumControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||
LifecycleManager lifecycleManager, ContactManager contactManager,
|
||||
AuthorManager authorManager,
|
||||
ConversationManager conversationManager,
|
||||
ForumSharingManager forumSharingManager, Clock clock) {
|
||||
ForumSharingManager forumSharingManager) {
|
||||
super(dbExecutor, lifecycleManager, contactManager, authorManager);
|
||||
this.conversationManager = conversationManager;
|
||||
this.forumSharingManager = forumSharingManager;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,10 +58,7 @@ class ShareForumControllerImpl extends ContactSelectorControllerImpl
|
||||
try {
|
||||
for (ContactId c : contacts) {
|
||||
try {
|
||||
long time = Math.max(clock.currentTimeMillis(),
|
||||
conversationManager.getGroupCount(c)
|
||||
.getLatestMsgTime() + 1);
|
||||
forumSharingManager.sendInvitation(g, c, text, time);
|
||||
forumSharingManager.sendInvitation(g, c, text);
|
||||
} catch (NoSuchContactException | NoSuchGroupException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface ConversationManager {
|
||||
|
||||
/**
|
||||
* Returns a timestamp for an outgoing message, which is later than the
|
||||
* timestamp of any visible message sent or received so far.
|
||||
* timestamp of any message in the conversation with the given contact.
|
||||
*/
|
||||
long getTimestampForOutgoingMessage(Transaction txn, ContactId c)
|
||||
throws DbException;
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface SharingManager<S extends Shareable>
|
||||
* including optional text.
|
||||
*/
|
||||
void sendInvitation(GroupId shareableId, ContactId contactId,
|
||||
@Nullable String text, long timestamp) throws DbException;
|
||||
@Nullable String text) throws DbException;
|
||||
|
||||
/**
|
||||
* Responds to a pending group invitation
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||
import org.briarproject.briar.api.blog.Blog;
|
||||
@@ -19,6 +18,7 @@ import org.briarproject.briar.api.blog.BlogSharingManager;
|
||||
import org.briarproject.briar.api.blog.event.BlogInvitationRequestReceivedEvent;
|
||||
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.conversation.ConversationRequest;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -41,13 +41,14 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
||||
MessageParser<Blog> messageParser,
|
||||
MessageTracker messageTracker,
|
||||
AutoDeleteManager autoDeleteManager,
|
||||
Clock clock,
|
||||
ConversationManager conversationManager,
|
||||
BlogManager blogManager,
|
||||
InvitationFactory<Blog, BlogInvitationResponse> invitationFactory) {
|
||||
super(db, clientHelper, clientVersioningManager, messageEncoder,
|
||||
messageParser, messageTracker, autoDeleteManager, clock,
|
||||
BlogSharingManager.CLIENT_ID, BlogSharingManager.MAJOR_VERSION,
|
||||
BlogManager.CLIENT_ID, BlogManager.MAJOR_VERSION);
|
||||
messageParser, messageTracker, autoDeleteManager,
|
||||
conversationManager, BlogSharingManager.CLIENT_ID,
|
||||
BlogSharingManager.MAJOR_VERSION, BlogManager.CLIENT_ID,
|
||||
BlogManager.MAJOR_VERSION);
|
||||
this.blogManager = blogManager;
|
||||
this.invitationFactory = invitationFactory;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.conversation.ConversationRequest;
|
||||
import org.briarproject.briar.api.forum.Forum;
|
||||
import org.briarproject.briar.api.forum.ForumInvitationResponse;
|
||||
@@ -41,14 +41,14 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
||||
MessageParser<Forum> messageParser,
|
||||
MessageTracker messageTracker,
|
||||
AutoDeleteManager autoDeleteManager,
|
||||
Clock clock,
|
||||
ConversationManager conversationManager,
|
||||
ForumManager forumManager,
|
||||
InvitationFactory<Forum, ForumInvitationResponse> invitationFactory) {
|
||||
super(db, clientHelper, clientVersioningManager, messageEncoder,
|
||||
messageParser, messageTracker, autoDeleteManager, clock,
|
||||
ForumSharingManager.CLIENT_ID,
|
||||
ForumSharingManager.MAJOR_VERSION,
|
||||
ForumManager.CLIENT_ID, ForumManager.MAJOR_VERSION);
|
||||
messageParser, messageTracker, autoDeleteManager,
|
||||
conversationManager, ForumSharingManager.CLIENT_ID,
|
||||
ForumSharingManager.MAJOR_VERSION, ForumManager.CLIENT_ID,
|
||||
ForumManager.MAJOR_VERSION);
|
||||
this.forumManager = forumManager;
|
||||
this.invitationFactory = invitationFactory;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import javax.annotation.Nullable;
|
||||
interface ProtocolEngine<S extends Shareable> {
|
||||
|
||||
Session onInviteAction(Transaction txn, Session session,
|
||||
@Nullable String text, long timestamp) throws DbException;
|
||||
@Nullable String text) throws DbException;
|
||||
|
||||
Session onAcceptAction(Transaction txn, Session session) throws DbException;
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.briarproject.bramble.api.sync.Group.Visibility;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.ProtocolStateException;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.sharing.Shareable;
|
||||
import org.briarproject.briar.api.sharing.event.ContactLeftShareableEvent;
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.INVISIBLE;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.VISIBLE;
|
||||
@@ -58,7 +59,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
private final MessageEncoder messageEncoder;
|
||||
private final MessageTracker messageTracker;
|
||||
private final AutoDeleteManager autoDeleteManager;
|
||||
private final Clock clock;
|
||||
private final ConversationManager conversationManager;
|
||||
private final ClientId sharingClientId, shareableClientId;
|
||||
private final int sharingClientMajorVersion, shareableClientMajorVersion;
|
||||
|
||||
@@ -70,7 +71,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
MessageParser<S> messageParser,
|
||||
MessageTracker messageTracker,
|
||||
AutoDeleteManager autoDeleteManager,
|
||||
Clock clock,
|
||||
ConversationManager conversationManager,
|
||||
ClientId sharingClientId,
|
||||
int sharingClientMajorVersion,
|
||||
ClientId shareableClientId,
|
||||
@@ -82,7 +83,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
this.messageParser = messageParser;
|
||||
this.messageTracker = messageTracker;
|
||||
this.autoDeleteManager = autoDeleteManager;
|
||||
this.clock = clock;
|
||||
this.conversationManager = conversationManager;
|
||||
this.sharingClientId = sharingClientId;
|
||||
this.sharingClientMajorVersion = sharingClientMajorVersion;
|
||||
this.shareableClientId = shareableClientId;
|
||||
@@ -91,10 +92,10 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
|
||||
@Override
|
||||
public Session onInviteAction(Transaction txn, Session s,
|
||||
@Nullable String text, long timestamp) throws DbException {
|
||||
@Nullable String text) throws DbException {
|
||||
switch (s.getState()) {
|
||||
case START:
|
||||
return onLocalInvite(txn, s, text, timestamp);
|
||||
return onLocalInvite(txn, s, text);
|
||||
case LOCAL_INVITED:
|
||||
case REMOTE_INVITED:
|
||||
case SHARING:
|
||||
@@ -107,9 +108,9 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
}
|
||||
|
||||
private Session onLocalInvite(Transaction txn, Session s,
|
||||
@Nullable String text, long timestamp) throws DbException {
|
||||
@Nullable String text) throws DbException {
|
||||
// Send an INVITE message
|
||||
Message sent = sendInviteMessage(txn, s, text, timestamp);
|
||||
Message sent = sendInviteMessage(txn, s, text);
|
||||
// Track the message
|
||||
messageTracker.trackOutgoingMessage(txn, sent);
|
||||
// Make the shareable visible to the contact
|
||||
@@ -125,7 +126,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
}
|
||||
|
||||
private Message sendInviteMessage(Transaction txn, Session s,
|
||||
@Nullable String text, long timestamp) throws DbException {
|
||||
@Nullable String text) throws DbException {
|
||||
Group g = db.getGroup(txn, s.getShareableId());
|
||||
BdfList descriptor;
|
||||
try {
|
||||
@@ -133,7 +134,7 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e); // Invalid group descriptor
|
||||
}
|
||||
long localTimestamp = Math.max(timestamp, getLocalTimestamp(s));
|
||||
long localTimestamp = getLocalTimestamp(txn, s);
|
||||
Message m;
|
||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||
if (contactSupportsAutoDeletion(txn, c)) {
|
||||
@@ -201,16 +202,17 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
private Message sendAcceptMessage(Transaction txn, Session s)
|
||||
throws DbException {
|
||||
Message m;
|
||||
long localTimestamp = getLocalTimestamp(txn, s);
|
||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||
if (contactSupportsAutoDeletion(txn, c)) {
|
||||
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
||||
m = messageEncoder.encodeAcceptMessage(s.getContactGroupId(),
|
||||
s.getShareableId(), getLocalTimestamp(s),
|
||||
s.getShareableId(), localTimestamp,
|
||||
s.getLastLocalMessageId(), timer);
|
||||
sendMessage(txn, m, ACCEPT, s.getShareableId(), true, timer);
|
||||
} else {
|
||||
m = messageEncoder.encodeAcceptMessage(s.getContactGroupId(),
|
||||
s.getShareableId(), getLocalTimestamp(s),
|
||||
s.getShareableId(), localTimestamp,
|
||||
s.getLastLocalMessageId());
|
||||
sendMessage(txn, m, ACCEPT, s.getShareableId(), true,
|
||||
NO_AUTO_DELETE_TIMER);
|
||||
@@ -254,16 +256,17 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
private Message sendDeclineMessage(Transaction txn, Session s)
|
||||
throws DbException {
|
||||
Message m;
|
||||
long localTimestamp = getLocalTimestamp(txn, s);
|
||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||
if (contactSupportsAutoDeletion(txn, c)) {
|
||||
long timer = autoDeleteManager.getAutoDeleteTimer(txn, c);
|
||||
m = messageEncoder.encodeDeclineMessage(s.getContactGroupId(),
|
||||
s.getShareableId(), getLocalTimestamp(s),
|
||||
s.getShareableId(), localTimestamp,
|
||||
s.getLastLocalMessageId(), timer);
|
||||
sendMessage(txn, m, DECLINE, s.getShareableId(), true, timer);
|
||||
} else {
|
||||
m = messageEncoder.encodeDeclineMessage(s.getContactGroupId(),
|
||||
s.getShareableId(), getLocalTimestamp(s),
|
||||
s.getShareableId(), localTimestamp,
|
||||
s.getLastLocalMessageId());
|
||||
sendMessage(txn, m, DECLINE, s.getShareableId(), true,
|
||||
NO_AUTO_DELETE_TIMER);
|
||||
@@ -307,9 +310,10 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
|
||||
private Message sendLeaveMessage(Transaction txn, Session session)
|
||||
throws DbException {
|
||||
long localTimestamp = getLocalTimestamp(txn, session);
|
||||
Message m = messageEncoder.encodeLeaveMessage(
|
||||
session.getContactGroupId(), session.getShareableId(),
|
||||
getLocalTimestamp(session), session.getLastLocalMessageId());
|
||||
localTimestamp, session.getLastLocalMessageId());
|
||||
sendMessage(txn, m, LEAVE, session.getShareableId(), false,
|
||||
NO_AUTO_DELETE_TIMER);
|
||||
return m;
|
||||
@@ -605,9 +609,10 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
|
||||
private Message sendAbortMessage(Transaction txn, Session session)
|
||||
throws DbException {
|
||||
long localTimestamp = getLocalTimestamp(txn, session);
|
||||
Message m = messageEncoder.encodeAbortMessage(
|
||||
session.getContactGroupId(), session.getShareableId(),
|
||||
getLocalTimestamp(session), session.getLastLocalMessageId());
|
||||
localTimestamp, session.getLastLocalMessageId());
|
||||
sendMessage(txn, m, ABORT, session.getShareableId(), false,
|
||||
NO_AUTO_DELETE_TIMER);
|
||||
return m;
|
||||
@@ -677,10 +682,19 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
return !dependency.equals(expected);
|
||||
}
|
||||
|
||||
private long getLocalTimestamp(Session session) {
|
||||
return Math.max(clock.currentTimeMillis(),
|
||||
Math.max(session.getLocalTimestamp(),
|
||||
session.getInviteTimestamp()) + 1);
|
||||
/**
|
||||
* Returns a timestamp for an outgoing message, which is later than the
|
||||
* timestamp of any message sent or received so far in the conversation
|
||||
* or the session.
|
||||
*/
|
||||
private long getLocalTimestamp(Transaction txn, Session session)
|
||||
throws DbException {
|
||||
ContactId c = getContactId(txn, session.getContactGroupId());
|
||||
long conversationTimestamp =
|
||||
conversationManager.getTimestampForOutgoingMessage(txn, c);
|
||||
long sessionTimestamp = max(session.getLocalTimestamp(),
|
||||
session.getInviteTimestamp()) + 1;
|
||||
return max(conversationTimestamp, sessionTimestamp);
|
||||
}
|
||||
|
||||
private ContactId getContactId(Transaction txn, GroupId contactGroupId)
|
||||
|
||||
@@ -248,7 +248,7 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
|
||||
@Override
|
||||
public void sendInvitation(GroupId shareableId, ContactId contactId,
|
||||
@Nullable String text, long timestamp) throws DbException {
|
||||
@Nullable String text) throws DbException {
|
||||
SessionId sessionId = getSessionId(shareableId);
|
||||
Transaction txn = db.startTransaction(false);
|
||||
try {
|
||||
@@ -273,7 +273,7 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
storageId = ss.storageId;
|
||||
}
|
||||
// Handle the invite action
|
||||
session = engine.onInviteAction(txn, session, text, timestamp);
|
||||
session = engine.onInviteAction(txn, session, text);
|
||||
// Store the updated session
|
||||
storeSession(txn, storageId, session);
|
||||
db.commitTransaction(txn);
|
||||
|
||||
@@ -45,8 +45,7 @@ public class ForumManagerTest
|
||||
forum0 = forumManager0.addForum("Test Forum");
|
||||
groupId0 = forum0.getId();
|
||||
// share forum
|
||||
forumSharingManager0.sendInvitation(groupId0, contactId1From0, null,
|
||||
clock.currentTimeMillis());
|
||||
forumSharingManager0.sendInvitation(groupId0, contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
forumSharingManager1.respondToInvitation(forum0, contact0From1, true);
|
||||
sync1To0(1, true);
|
||||
@@ -194,8 +193,7 @@ public class ForumManagerTest
|
||||
// share a second forum
|
||||
Forum forum1 = forumManager0.addForum("Test Forum1");
|
||||
GroupId g1 = forum1.getId();
|
||||
forumSharingManager0.sendInvitation(g1, contactId1From0, null,
|
||||
clock.currentTimeMillis());
|
||||
forumSharingManager0.sendInvitation(g1, contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
forumSharingManager1.respondToInvitation(forum1, contact0From1, true);
|
||||
sync1To0(1, true);
|
||||
|
||||
@@ -122,8 +122,7 @@ public class BlogSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
blogSharingManager0
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// invitee has own blog and that of the sharer
|
||||
assertEquals(2, blogManager1.getBlogs().size());
|
||||
@@ -213,8 +212,8 @@ public class BlogSharingIntegrationTest
|
||||
blogManager0.addBlog(rssBlog);
|
||||
|
||||
// send invitation
|
||||
blogSharingManager0.sendInvitation(rssBlog.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
blogSharingManager0
|
||||
.sendInvitation(rssBlog.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// invitee has own blog and that of the sharer
|
||||
assertEquals(2, blogManager1.getBlogs().size());
|
||||
@@ -285,8 +284,7 @@ public class BlogSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
blogSharingManager0
|
||||
.sendInvitation(blog2.getId(), contactId1From0, null,
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(blog2.getId(), contactId1From0, null);
|
||||
|
||||
// sync first request message
|
||||
sync0To1(1, true);
|
||||
@@ -341,8 +339,7 @@ public class BlogSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
blogSharingManager0
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync first request message
|
||||
sync0To1(1, true);
|
||||
@@ -398,8 +395,7 @@ public class BlogSharingIntegrationTest
|
||||
|
||||
// sharer sends invitation for 2's blog to 1
|
||||
blogSharingManager0
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync first request message
|
||||
sync0To1(1, true);
|
||||
@@ -436,8 +432,7 @@ public class BlogSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
blogSharingManager0
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync first request message
|
||||
sync0To1(1, true);
|
||||
@@ -515,8 +510,7 @@ public class BlogSharingIntegrationTest
|
||||
|
||||
// sharer sends invitation for 2's blog to 1
|
||||
blogSharingManager0
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(blog2.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync first request message
|
||||
sync0To1(1, true);
|
||||
|
||||
@@ -126,8 +126,7 @@ public class ForumSharingIntegrationTest
|
||||
public void testSuccessfulSharing() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// check that request message state is correct
|
||||
Collection<ConversationMessageHeader> messages = getMessages1From0();
|
||||
@@ -191,8 +190,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testDeclinedSharing() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -243,8 +242,8 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// 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());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
|
||||
// reset listener state for new request
|
||||
listener1.requestReceived = false;
|
||||
@@ -259,8 +258,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testInviteeLeavesAfterFinished() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -322,8 +321,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testSharerLeavesAfterFinished() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -383,8 +382,8 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// 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());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
|
||||
// reset listener state for new request
|
||||
listener1.requestReceived = false;
|
||||
@@ -399,8 +398,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testSharerLeavesBeforeResponse() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
|
||||
// sharer un-subscribes from forum
|
||||
forumManager0.removeForum(forum);
|
||||
@@ -420,8 +419,7 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null,
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -445,8 +443,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testSharingSameForumWithEachOther() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -471,10 +469,9 @@ public class ForumSharingIntegrationTest
|
||||
assertEquals(1, forumManager1.getForums().size());
|
||||
|
||||
// invitee now shares same forum back
|
||||
forumSharingManager1.sendInvitation(forum.getId(),
|
||||
contactId0From1,
|
||||
"I am re-sharing this forum with you.",
|
||||
clock.currentTimeMillis());
|
||||
forumSharingManager1
|
||||
.sendInvitation(forum.getId(), contactId0From1,
|
||||
"I am re-sharing this forum with you.");
|
||||
|
||||
// assert that the last invitation wasn't send
|
||||
assertEquals(2, c1.getMessageTracker().getGroupCount(group.getId())
|
||||
@@ -485,8 +482,8 @@ public class ForumSharingIntegrationTest
|
||||
public void testSharingSameForumWithEachOtherBeforeAccept()
|
||||
throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertRequestReceived(listener1, contactId0From1);
|
||||
@@ -501,10 +498,9 @@ public class ForumSharingIntegrationTest
|
||||
.getMsgCount());
|
||||
|
||||
// invitee now shares same forum back
|
||||
forumSharingManager1.sendInvitation(forum.getId(),
|
||||
contactId0From1,
|
||||
"I am re-sharing this forum with you.",
|
||||
clock.currentTimeMillis());
|
||||
forumSharingManager1
|
||||
.sendInvitation(forum.getId(), contactId0From1,
|
||||
"I am re-sharing this forum with you.");
|
||||
|
||||
// assert that the last invitation wasn't send
|
||||
assertEquals(1, c1.getMessageTracker().getGroupCount(group.getId())
|
||||
@@ -518,13 +514,12 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// invitee now shares same forum back
|
||||
forumSharingManager1.sendInvitation(forum.getId(),
|
||||
contactId0From1, "I am re-sharing this forum with you.",
|
||||
clock.currentTimeMillis());
|
||||
forumSharingManager1
|
||||
.sendInvitation(forum.getId(), contactId0From1,
|
||||
"I am re-sharing this forum with you.");
|
||||
|
||||
// only now sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -554,8 +549,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testContactRemoved() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -597,8 +592,7 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -626,8 +620,7 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// send invitation
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -637,8 +630,7 @@ public class ForumSharingIntegrationTest
|
||||
// second sharer sends invitation for same forum
|
||||
assertNotNull(contactId1From2);
|
||||
forumSharingManager2
|
||||
.sendInvitation(forum.getId(), contactId1From2, null,
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From2, null);
|
||||
|
||||
// sync second request message
|
||||
sync2To1(1, true);
|
||||
@@ -680,8 +672,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testSyncAfterReSharing() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -745,8 +737,7 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// send invitation again
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!",
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -787,8 +778,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testSessionResetAfterAbort() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
"Hi!", clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, "Hi!");
|
||||
|
||||
// sync request message
|
||||
sync0To1(1, true);
|
||||
@@ -836,8 +827,7 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// new invitation is possible now
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null,
|
||||
clock.currentTimeMillis());
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertRequestReceived(listener1, contactId0From1);
|
||||
@@ -859,8 +849,8 @@ public class ForumSharingIntegrationTest
|
||||
public void testDeletingAllMessagesWhenCompletingSession()
|
||||
throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
@@ -909,8 +899,8 @@ public class ForumSharingIntegrationTest
|
||||
sync1To0(1, true);
|
||||
|
||||
// sending invitation is possible again
|
||||
forumSharingManager1.sendInvitation(forum.getId(), contactId0From1,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager1
|
||||
.sendInvitation(forum.getId(), contactId0From1, null);
|
||||
sync1To0(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
@@ -944,8 +934,8 @@ public class ForumSharingIntegrationTest
|
||||
public void testDeletingAllMessagesAfterDecline()
|
||||
throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
@@ -969,8 +959,8 @@ public class ForumSharingIntegrationTest
|
||||
assertEquals(0, getMessages0From1().size());
|
||||
|
||||
// re-sending invitation is possible
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
@@ -984,8 +974,8 @@ public class ForumSharingIntegrationTest
|
||||
@Test
|
||||
public void testDeletingSomeMessages() throws Exception {
|
||||
// send invitation
|
||||
forumSharingManager0.sendInvitation(forum.getId(), contactId1From0,
|
||||
null, clock.currentTimeMillis());
|
||||
forumSharingManager0
|
||||
.sendInvitation(forum.getId(), contactId1From0, null);
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
@@ -996,7 +986,8 @@ public class ForumSharingIntegrationTest
|
||||
Set<MessageId> toDelete = new HashSet<>();
|
||||
toDelete.add(messageId);
|
||||
assertFalse(deleteMessages1From0(toDelete).allDeleted());
|
||||
assertTrue(deleteMessages1From0(toDelete).hasInvitationSessionInProgress());
|
||||
assertTrue(deleteMessages1From0(toDelete)
|
||||
.hasInvitationSessionInProgress());
|
||||
|
||||
// decline invitation
|
||||
respondToRequest(contactId0From1, true);
|
||||
@@ -1006,9 +997,11 @@ public class ForumSharingIntegrationTest
|
||||
// both can still not delete the invitation,
|
||||
// because the response was not selected for deletion as well
|
||||
assertFalse(deleteMessages1From0(toDelete).allDeleted());
|
||||
assertTrue(deleteMessages1From0(toDelete).hasNotAllInvitationSelected());
|
||||
assertTrue(
|
||||
deleteMessages1From0(toDelete).hasNotAllInvitationSelected());
|
||||
assertFalse(deleteMessages0From1(toDelete).allDeleted());
|
||||
assertTrue(deleteMessages0From1(toDelete).hasNotAllInvitationSelected());
|
||||
assertTrue(
|
||||
deleteMessages0From1(toDelete).hasNotAllInvitationSelected());
|
||||
|
||||
// after selecting response, both messages can be deleted
|
||||
m0 = getMessages1From0();
|
||||
@@ -1023,8 +1016,10 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// 1 can still not delete the messages, as last one has not been ACKed
|
||||
assertFalse(deleteMessages0From1(toDelete).allDeleted());
|
||||
assertFalse(deleteMessages0From1(toDelete).hasNotAllInvitationSelected());
|
||||
assertTrue(deleteMessages0From1(toDelete).hasInvitationSessionInProgress());
|
||||
assertFalse(
|
||||
deleteMessages0From1(toDelete).hasNotAllInvitationSelected());
|
||||
assertTrue(deleteMessages0From1(toDelete)
|
||||
.hasInvitationSessionInProgress());
|
||||
|
||||
// 0 sends an ACK to their last message
|
||||
sendAcks(c0, c1, contactId1From0, 1);
|
||||
|
||||
Reference in New Issue
Block a user