Add GroupId to conversation items

This commit is contained in:
Torsten Grote
2016-10-05 12:09:08 -03:00
parent 1731369d7a
commit 457c30f3f2
27 changed files with 158 additions and 113 deletions

View File

@@ -12,6 +12,7 @@ import org.briarproject.api.introduction.IntroduceeAction;
import org.briarproject.api.introduction.IntroduceeProtocolState;
import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import java.util.ArrayList;
@@ -343,6 +344,7 @@ public class IntroduceeEngine
SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID));
MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID));
GroupId groupId = new GroupId(msg.getRaw(GROUP_ID));
long time = msg.getLong(MESSAGE_TIME);
String name = msg.getString(NAME);
String message = msg.getOptionalString(MSG);
@@ -351,8 +353,9 @@ public class IntroduceeEngine
localState.getBoolean(REMOTE_AUTHOR_IS_US);
IntroductionRequest ir = new IntroductionRequest(sessionId, messageId,
ROLE_INTRODUCEE, time, false, false, false, false, authorId,
name, false, message, false, exists, introducesOtherIdentity);
groupId, ROLE_INTRODUCEE, time, false, false, false, false,
authorId, name, false, message, false, exists,
introducesOtherIdentity);
return new IntroductionRequestReceivedEvent(contactId, ir);
}

View File

@@ -12,6 +12,7 @@ import org.briarproject.api.introduction.IntroducerAction;
import org.briarproject.api.introduction.IntroducerProtocolState;
import org.briarproject.api.introduction.IntroductionResponse;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import java.util.ArrayList;
@@ -298,14 +299,15 @@ public class IntroducerEngine
SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID));
MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID));
GroupId groupId = new GroupId(msg.getRaw(GROUP_ID));
long time = msg.getLong(MESSAGE_TIME);
String name = getOtherContact(localState, msg);
boolean accept = msg.getBoolean(ACCEPT);
IntroductionResponse ir =
new IntroductionResponse(sessionId, messageId, ROLE_INTRODUCER,
time, false, false, false, false, authorId, name,
accept);
new IntroductionResponse(sessionId, messageId, groupId,
ROLE_INTRODUCER, time, false, false, false, false,
authorId, name, accept);
return new IntroductionResponseReceivedEvent(contactId, ir);
}

View File

@@ -415,7 +415,7 @@ class IntroductionManagerImpl extends BdfIncomingMessageHook
name = state.getString(NAME);
}
IntroductionResponse ir = new IntroductionResponse(
sessionId, messageId, role, time, local,
sessionId, messageId, g, role, time, local,
s.isSent(), s.isSeen(), read, authorId, name,
accepted);
list.add(ir);
@@ -445,7 +445,7 @@ class IntroductionManagerImpl extends BdfIncomingMessageHook
state.getBoolean(REMOTE_AUTHOR_IS_US);
}
IntroductionRequest ir = new IntroductionRequest(
sessionId, messageId, role, time, local,
sessionId, messageId, g, role, time, local,
s.isSent(), s.isSeen(), read, authorId, name,
accepted, message, answered, exists,
introducesOtherIdentity);

View File

@@ -101,7 +101,8 @@ class MessagingManagerImpl extends BdfIncomingMessageHook
boolean local = meta.getBoolean("local");
boolean read = meta.getBoolean(MSG_KEY_READ);
PrivateMessageHeader header = new PrivateMessageHeader(
m.getId(), timestamp, contentType, local, read, false, false);
m.getId(), m.getGroupId(), timestamp, contentType, local, read,
false, false);
PrivateMessageReceivedEvent event = new PrivateMessageReceivedEvent(
header, groupId);
txn.attach(event);
@@ -159,9 +160,10 @@ class MessagingManagerImpl extends BdfIncomingMessageHook
throws DbException {
Map<MessageId, BdfDictionary> metadata;
Collection<MessageStatus> statuses;
GroupId g;
Transaction txn = db.startTransaction(true);
try {
GroupId g = getContactGroup(db.getContact(txn, c)).getId();
g = getContactGroup(db.getContact(txn, c)).getId();
metadata = clientHelper.getMessageMetadataAsDictionary(txn, g);
statuses = db.getMessageStatus(txn, c, g);
txn.setComplete();
@@ -181,8 +183,8 @@ class MessagingManagerImpl extends BdfIncomingMessageHook
String contentType = meta.getString("contentType");
boolean local = meta.getBoolean("local");
boolean read = meta.getBoolean("read");
headers.add(new PrivateMessageHeader(id, timestamp, contentType,
local, read, s.isSent(), s.isSeen()));
headers.add(new PrivateMessageHeader(id, g, timestamp,
contentType, local, read, s.isSent(), s.isSeen()));
} catch (FormatException e) {
throw new DbException(e);
}

View File

@@ -109,17 +109,18 @@ class BlogSharingManagerImpl extends
BlogInvitation msg, ContactId contactId, boolean available,
long time, boolean local, boolean sent, boolean seen,
boolean read) {
return new BlogInvitationRequest(id, msg.getSessionId(), contactId,
msg.getBlogAuthorName(), msg.getMessage(), available, time,
local, sent, seen, read);
return new BlogInvitationRequest(id, msg.getSessionId(),
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
msg.getMessage(), available, time, local, sent, seen, read);
}
@Override
protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, ContactId contactId, boolean accept, long time,
SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time,
boolean local, boolean sent, boolean seen, boolean read) {
return new BlogInvitationResponse(id, sessionId, contactId, accept,
time, local, sent, seen, read);
return new BlogInvitationResponse(id, sessionId, groupId, contactId,
accept, time, local, sent, seen, read);
}
@Override
@@ -321,9 +322,9 @@ class BlogSharingManagerImpl extends
ContactId contactId = localState.getContactId();
BlogInvitationRequest request =
new BlogInvitationRequest(localState.getInvitationId(),
localState.getSessionId(), contactId,
blog.getAuthor().getName(), msg, true, time, false,
false, false, false);
localState.getSessionId(), localState.getGroupId(),
contactId, blog.getAuthor().getName(), msg, true,
time, false, false, false, false);
return new BlogInvitationReceivedEvent(blog, contactId, request);
}
}
@@ -337,7 +338,7 @@ class BlogSharingManagerImpl extends
ContactId c = localState.getContactId();
BlogInvitationResponse response =
new BlogInvitationResponse(localState.getResponseId(),
localState.getSessionId(),
localState.getSessionId(), localState.getGroupId(),
localState.getContactId(), accept, time, false,
false, false, false);
return new BlogInvitationResponseReceivedEvent(title, c, response);

View File

@@ -83,17 +83,18 @@ class ForumSharingManagerImpl extends
ForumInvitation msg, ContactId contactId, boolean available,
long time, boolean local, boolean sent, boolean seen,
boolean read) {
return new ForumInvitationRequest(id, msg.getSessionId(), contactId,
msg.getForumName(), msg.getMessage(), available, time, local,
sent, seen, read);
return new ForumInvitationRequest(id, msg.getSessionId(),
msg.getGroupId(), contactId, msg.getForumName(),
msg.getMessage(), available, time, local, sent, seen, read);
}
@Override
protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, ContactId contactId, boolean accept,
long time, boolean local, boolean sent, boolean seen, boolean read) {
return new ForumInvitationResponse(id, sessionId, contactId, accept,
time, local, sent, seen, read);
SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read) {
return new ForumInvitationResponse(id, sessionId, groupId, contactId,
accept, time, local, sent, seen, read);
}
@Override
@@ -268,8 +269,8 @@ class ForumSharingManagerImpl extends
ContactId contactId = localState.getContactId();
ForumInvitationRequest request = new ForumInvitationRequest(
localState.getInvitationId(), localState.getSessionId(),
contactId, forum.getName(), msg, true, time, false, false,
false, false);
localState.getGroupId(), contactId, forum.getName(), msg,
true, time, false, false, false, false);
return new ForumInvitationReceivedEvent(forum, contactId, request);
}
}
@@ -282,9 +283,9 @@ class ForumSharingManagerImpl extends
String name = localState.getForumName();
ContactId c = localState.getContactId();
ForumInvitationResponse response = new ForumInvitationResponse(
localState.getResponseId(),
localState.getSessionId(), localState.getContactId(),
accept, time, false, false, false, false);
localState.getResponseId(), localState.getSessionId(),
localState.getGroupId(), localState.getContactId(), accept,
time, false, false, false, false);
return new ForumInvitationResponseReceivedEvent(name, c, response);
}
}

View File

@@ -117,13 +117,14 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
public abstract ClientId getClientId();
protected abstract InvitationMessage createInvitationRequest(MessageId id, I msg,
ContactId contactId, boolean available, long time, boolean local,
boolean sent, boolean seen, boolean read);
protected abstract InvitationMessage createInvitationRequest(MessageId id,
I msg, ContactId contactId, boolean available, long time,
boolean local, boolean sent, boolean seen, boolean read);
protected abstract InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, ContactId contactId, boolean accept, long time,
boolean local, boolean sent, boolean seen, boolean read);
SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read);
protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
@@ -394,8 +395,9 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
.from(getIFactory(), group.getId(), d);
SessionId sessionId = msg.getSessionId();
InvitationMessage im = createInvitationResponse(
m.getKey(), sessionId, contactId, accept, time,
local, status.isSent(), status.isSeen(), read);
m.getKey(), sessionId, group.getId(), contactId,
accept, time, local, status.isSent(),
status.isSeen(), read);
list.add(im);
}
else {