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