ConversationManager: Address review issues

parent 2309e732
......@@ -70,34 +70,34 @@ class ConversationNoticeOutItem extends ConversationOutItem {
}
private static String getText(Context ctx, String contactName,
PrivateResponse ir) {
if (ir.wasAccepted()) {
if (ir instanceof IntroductionResponse) {
String name = ((IntroductionResponse) ir).getIntroducedAuthor()
PrivateResponse r) {
if (r.wasAccepted()) {
if (r instanceof IntroductionResponse) {
String name = ((IntroductionResponse) r).getIntroducedAuthor()
.getName();
return ctx.getString(
R.string.introduction_response_accepted_sent,
name) + "\n\n" + ctx.getString(
R.string.introduction_response_accepted_sent_info,
name);
} else if (ir instanceof ForumInvitationResponse) {
} else if (r instanceof ForumInvitationResponse) {
return ctx.getString(R.string.forum_invitation_response_accepted_sent, contactName);
} else if (ir instanceof BlogInvitationResponse) {
} else if (r instanceof BlogInvitationResponse) {
return ctx.getString(R.string.blogs_sharing_response_accepted_sent, contactName);
} else if (ir instanceof GroupInvitationResponse) {
} else if (r instanceof GroupInvitationResponse) {
return ctx.getString(R.string.groups_invitations_response_accepted_sent, contactName);
}
} else {
if (ir instanceof IntroductionResponse) {
String name = ((IntroductionResponse) ir).getIntroducedAuthor()
if (r instanceof IntroductionResponse) {
String name = ((IntroductionResponse) r).getIntroducedAuthor()
.getName();
return ctx.getString(
R.string.introduction_response_declined_sent, name);
} else if (ir instanceof ForumInvitationResponse) {
} else if (r instanceof ForumInvitationResponse) {
return ctx.getString(R.string.forum_invitation_response_declined_sent, contactName);
} else if (ir instanceof BlogInvitationResponse) {
} else if (r instanceof BlogInvitationResponse) {
return ctx.getString(R.string.blogs_sharing_response_declined_sent, contactName);
} else if (ir instanceof GroupInvitationResponse) {
} else if (r instanceof GroupInvitationResponse) {
return ctx.getString(R.string.groups_invitations_response_declined_sent, contactName);
}
}
......
......@@ -256,7 +256,7 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
GroupInvitationMessage m, boolean accept) {
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
return new GroupInvitationResponse(m.getId(), m.getContactGroupId(),
m.getTimestamp(), false, false, true, false, sessionId,
m.getTimestamp(), false, false, false, false, sessionId,
accept, m.getPrivateGroupId());
}
}
......@@ -61,7 +61,7 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
ContactId contactId) {
BlogInvitationResponse response = invitationFactory
.createInvitationResponse(m.getId(), m.getContactGroupId(),
m.getTimestamp(), false, false, true, false,
m.getTimestamp(), false, false, false, false,
true, m.getShareableId());
return new BlogInvitationResponseReceivedEvent(response, contactId);
}
......@@ -71,8 +71,8 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
ContactId contactId) {
BlogInvitationResponse response = invitationFactory
.createInvitationResponse(m.getId(), m.getContactGroupId(),
m.getTimestamp(), false, false, true, false,
true, m.getShareableId());
m.getTimestamp(), false, false, false, false,
false, m.getShareableId());
return new BlogInvitationResponseReceivedEvent(response, contactId);
}
......
......@@ -73,7 +73,7 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
ForumInvitationResponse response = invitationFactory
.createInvitationResponse(m.getId(), m.getContactGroupId(),
m.getTimestamp(), false, false, true, false,
true, m.getShareableId());
false, m.getShareableId());
return new ForumInvitationResponseReceivedEvent(response, contactId);
}
......
......@@ -368,13 +368,16 @@ public class IntroductionIntegrationTest
.getMessageHeaders(txn, contactId1From0));
assertEquals(2, messages.size());
messages = withinTransactionReturns(db0,
txn -> introductionManager0.getMessageHeaders(txn, contactId2From0));
txn -> introductionManager0
.getMessageHeaders(txn, contactId2From0));
assertEquals(2, messages.size());
messages = withinTransactionReturns(db1,
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1));
assertEquals(3,messages.size());
txn -> introductionManager1
.getMessageHeaders(txn, contactId0From1));
assertEquals(3, messages.size());
messages = withinTransactionReturns(db2,
txn -> introductionManager2.getMessageHeaders(txn, contactId0From2));
txn -> introductionManager2
.getMessageHeaders(txn, contactId0From2));
assertEquals(3, messages.size());
assertFalse(listener0.aborted);
assertFalse(listener1.aborted);
......
......@@ -408,7 +408,7 @@ public class PrivateGroupManagerIntegrationTest
groupManager2.addPrivateGroup(txn, privateGroup0, joinMsg2, false);
// share the group with 0
db2.setGroupVisibility(txn,
contactId0From1, privateGroup0.getId(), SHARED); // TODO contactId
contactId0From2, privateGroup0.getId(), SHARED);
});
// sync join messages
......
......@@ -478,11 +478,11 @@ public class ForumSharingIntegrationTest
.contains(contact0From1));
// and both have each other's invitations (and no response)
assertEquals(2, withinTransactionReturns(db0, txn2 ->
forumSharingManager0.getMessageHeaders(txn2, contactId1From0))
assertEquals(2, withinTransactionReturns(db0, txn ->
forumSharingManager0.getMessageHeaders(txn, contactId1From0))
.size());
assertEquals(2, withinTransactionReturns(db1, txn2 ->
forumSharingManager1.getMessageHeaders(txn2, contactId0From1))
assertEquals(2, withinTransactionReturns(db1, txn ->
forumSharingManager1.getMessageHeaders(txn, contactId0From1))
.size());
// there are no more open invitations
......@@ -561,11 +561,11 @@ public class ForumSharingIntegrationTest
withinTransaction(db2, txn -> db2.addGroup(txn, forum0.getGroup()));
// add listeners
listener0 = new SharerListener();
listener0 = new SharerListener(true);
c0.getEventBus().addListener(listener0);
listener1 = new InviteeListener(true, false);
c1.getEventBus().addListener(listener1);
listener2 = new SharerListener();
listener2 = new SharerListener(true);
c2.getEventBus().addListener(listener2);
// send invitation
......@@ -790,13 +790,22 @@ public class ForumSharingIntegrationTest
@NotNullByDefault
private class SharerListener implements EventListener {
private final boolean accept;
private volatile boolean requestReceived = false;
private volatile boolean responseReceived = false;
private SharerListener(boolean accept) {
this.accept = accept;
}
@Override
public void eventOccurred(Event e) {
if (e instanceof ForumInvitationResponseReceivedEvent) {
ForumInvitationResponseReceivedEvent event =
(ForumInvitationResponseReceivedEvent) e;
responseReceived = true;
eventWaiter.assertEquals(accept,
event.getMessageHeader().wasAccepted());
eventWaiter.resume();
}
// this is only needed for tests where a forum is re-shared
......@@ -868,17 +877,19 @@ public class ForumSharingIntegrationTest
ForumInvitationResponseReceivedEvent event =
(ForumInvitationResponseReceivedEvent) e;
eventWaiter.assertEquals(contactId0From1, event.getContactId());
eventWaiter.assertEquals(accept,
event.getMessageHeader().wasAccepted());
eventWaiter.resume();
}
}
}
private void listenToEvents(boolean accept) throws DbException {
listener0 = new SharerListener();
private void listenToEvents(boolean accept) {
listener0 = new SharerListener(accept);
c0.getEventBus().addListener(listener0);
listener1 = new InviteeListener(accept);
c1.getEventBus().addListener(listener1);
listener2 = new SharerListener();
listener2 = new SharerListener(accept);
c2.getEventBus().addListener(listener2);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment