Show open button in private conversation after accepting invitations

This commit is contained in:
Torsten Grote
2016-12-13 10:28:25 -02:00
parent d63d15329c
commit 2ef9b8f4b6
23 changed files with 180 additions and 101 deletions

View File

@@ -255,7 +255,7 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
GroupInvitationMessage m, ContactId c, boolean accept) {
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
return new GroupInvitationResponse(m.getId(), sessionId,
m.getPrivateGroupId(), c, accept, m.getTimestamp(), false,
false, true, false);
m.getContactGroupId(), c, m.getPrivateGroupId(), accept,
m.getTimestamp(), false, false, true, false);
}
}

View File

@@ -381,10 +381,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
m, meta, status));
} else if (type == JOIN) {
messages.add(
parseInvitationResponse(c, m, meta, status, true));
parseInvitationResponse(c, contactGroupId, m, meta,
status, true));
} else if (type == LEAVE) {
messages.add(
parseInvitationResponse(c, m, meta, status, false));
parseInvitationResponse(c, contactGroupId, m, meta,
status, false));
}
}
db.commitTransaction(txn);
@@ -404,7 +406,8 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
// Look up the invite message to get the details of the private group
InviteMessage invite = getInviteMessage(txn, m);
return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
invite.getMessage(), invite.getGroupName(), invite.getCreator(),
invite.getMessage(), invite.getPrivateGroupId(),
invite.getGroupName(), invite.getCreator(),
meta.isAvailableToAnswer(), meta.getTimestamp(), meta.isLocal(),
status.isSent(), status.isSeen(), meta.isRead());
}
@@ -418,11 +421,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
}
private GroupInvitationResponse parseInvitationResponse(ContactId c,
MessageId m, MessageMetadata meta, MessageStatus status,
boolean accept) throws DbException, FormatException {
GroupId contactGroupId, MessageId m, MessageMetadata meta,
MessageStatus status, boolean accept)
throws DbException, FormatException {
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
return new GroupInvitationResponse(m, sessionId,
meta.getPrivateGroupId(), c, accept, meta.getTimestamp(),
return new GroupInvitationResponse(m, sessionId, contactGroupId, c,
meta.getPrivateGroupId(), accept, meta.getTimestamp(),
meta.isLocal(), status.isSent(), status.isSeen(),
meta.isRead());
}

View File

@@ -318,8 +318,8 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
ContactId c) {
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
return new GroupInvitationRequest(m.getId(), sessionId,
m.getContactGroupId(), c, m.getMessage(), m.getGroupName(),
m.getCreator(), true, m.getTimestamp(), false, false, true,
false);
m.getContactGroupId(), c, m.getMessage(), m.getPrivateGroupId(),
m.getGroupName(), m.getCreator(), true, m.getTimestamp(), false,
false, true, false);
}
}

View File

@@ -40,6 +40,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
import java.security.SecureRandom;
import java.util.Collection;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import javax.inject.Inject;
@@ -133,21 +134,23 @@ class BlogSharingManagerImpl extends
@Override
protected InvitationMessage createInvitationRequest(MessageId id,
BlogInvitation msg, ContactId contactId, boolean available,
long time, boolean local, boolean sent, boolean seen,
boolean read) {
BlogInvitation msg, ContactId contactId, GroupId blogId,
boolean available, long time, boolean local, boolean sent,
boolean seen, boolean read) {
return new BlogInvitationRequest(id, msg.getSessionId(),
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
msg.getMessage(), available, time, local, sent, seen, read);
msg.getMessage(), blogId, available, time, local, sent, seen,
read);
}
@Override
protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time,
boolean local, boolean sent, boolean seen, boolean read) {
GroupId blogId, boolean accept, long time, boolean local,
boolean sent, boolean seen, boolean read) {
return new BlogInvitationResponse(id, sessionId, groupId, contactId,
accept, time, local, sent, seen, read);
blogId, accept, time, local, sent, seen, read);
}
@Override
@@ -333,14 +336,17 @@ class BlogSharingManagerImpl extends
@Override
public BlogInvitationRequestReceivedEvent build(
BlogInviteeSessionState localState, long time, String msg) {
BlogInviteeSessionState localState, long time,
@Nullable String msg) {
Blog blog = sFactory.parse(localState);
ContactId contactId = localState.getContactId();
BlogInvitationRequest request =
new BlogInvitationRequest(localState.getInvitationId(),
localState.getSessionId(), localState.getContactGroupId(),
contactId, blog.getAuthor().getName(), msg, true,
time, false, false, false, false);
localState.getSessionId(),
localState.getContactGroupId(), contactId,
blog.getAuthor().getName(), msg,
localState.getShareableId(), true, time, false,
false, false, false);
return new BlogInvitationRequestReceivedEvent(blog, contactId,
request);
}
@@ -358,8 +364,9 @@ class BlogSharingManagerImpl extends
BlogInvitationResponse response =
new BlogInvitationResponse(responseId,
localState.getSessionId(),
localState.getShareableId(),
localState.getContactId(), accept, time, false,
localState.getContactGroupId(),
localState.getContactId(),
localState.getShareableId(), accept, time, false,
false, false, false);
return new BlogInvitationResponseReceivedEvent(c, response);
}

View File

@@ -33,6 +33,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
import java.security.SecureRandom;
import javax.annotation.Nullable;
import javax.inject.Inject;
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_NAME;
@@ -81,21 +82,21 @@ class ForumSharingManagerImpl extends
@Override
protected InvitationMessage createInvitationRequest(MessageId id,
ForumInvitation msg, ContactId contactId, boolean available,
long time, boolean local, boolean sent, boolean seen,
boolean read) {
ForumInvitation msg, ContactId contactId, GroupId forumId,
boolean available, long time, boolean local, boolean sent,
boolean seen, boolean read) {
return new ForumInvitationRequest(id, msg.getSessionId(),
msg.getGroupId(), contactId, msg.getForumName(),
msg.getGroupId(), contactId, forumId, msg.getForumName(),
msg.getMessage(), available, time, local, sent, seen, read);
}
@Override
protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read) {
GroupId forumId, 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);
forumId, accept, time, local, sent, seen, read);
}
@Override
@@ -263,13 +264,15 @@ class ForumSharingManagerImpl extends
@Override
public ForumInvitationRequestReceivedEvent build(
ForumInviteeSessionState localState, long time, String msg) {
ForumInviteeSessionState localState, long time,
@Nullable String msg) {
Forum forum = sFactory.parse(localState);
ContactId contactId = localState.getContactId();
ForumInvitationRequest request = new ForumInvitationRequest(
localState.getInvitationId(), localState.getSessionId(),
localState.getContactGroupId(), contactId, forum.getName(), msg,
true, time, false, false, false, false);
localState.getContactGroupId(), contactId,
localState.getShareableId(), forum.getName(), msg, true,
time, false, false, false, false);
return new ForumInvitationRequestReceivedEvent(forum, contactId,
request);
}
@@ -287,8 +290,9 @@ class ForumSharingManagerImpl extends
throw new IllegalStateException("No responseId");
ForumInvitationResponse response = new ForumInvitationResponse(
responseId, localState.getSessionId(),
localState.getShareableId(), localState.getContactId(),
accept, time, false, false, false, false);
localState.getContactGroupId(), localState.getContactId(),
localState.getShareableId(), accept, time, false, false,
false, false);
return new ForumInvitationResponseReceivedEvent(name, c, response);
}
}

View File

@@ -125,13 +125,13 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
protected 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);
I msg, ContactId contactId, GroupId shareableId, boolean available,
long time, boolean local, boolean sent, boolean seen, boolean read);
protected abstract InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read);
GroupId shareableId, boolean accept, long time, boolean local,
boolean sent, boolean seen, boolean read);
protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
@@ -391,6 +391,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
try {
MessageStatus status =
db.getMessageStatus(txn, contactId, m.getKey());
SharingSessionState s;
long time = d.getLong(TIME);
boolean local = d.getBoolean(LOCAL);
boolean read = d.getBoolean(MSG_KEY_READ, false);
@@ -398,11 +399,10 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
if (type == SHARE_MSG_TYPE_INVITATION) {
I msg = getIFactory().build(group.getId(), d);
SessionId sessionId = msg.getSessionId();
s = getSessionState(txn, sessionId, true);
if (!local) {
// figure out whether the shareable is still available
SharingSessionState s =
getSessionState(txn, msg.getSessionId(),
true);
if (!(s instanceof InviteeSessionState))
continue;
available = ((InviteeSessionState) s).getState() ==
@@ -410,8 +410,9 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
}
InvitationMessage im =
createInvitationRequest(m.getKey(), msg,
contactId, available, time, local,
status.isSent(), status.isSeen(), read);
contactId, s.getShareableId(),
available, time, local, status.isSent(),
status.isSeen(), read);
list.add(im);
} else if (type == SHARE_MSG_TYPE_ACCEPT ||
type == SHARE_MSG_TYPE_DECLINE) {
@@ -419,10 +420,12 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
BaseMessage msg = BaseMessage
.from(getIFactory(), group.getId(), d);
SessionId sessionId = msg.getSessionId();
InvitationMessage im = createInvitationResponse(
m.getKey(), sessionId, group.getId(), contactId,
accept, time, local, status.isSent(),
status.isSeen(), read);
s = getSessionState(txn, sessionId, true);
InvitationMessage im =
createInvitationResponse(m.getKey(), sessionId,
group.getId(), contactId,
s.getShareableId(), accept, time, local,
status.isSent(), status.isSeen(), read);
list.add(im);
} else {
throw new RuntimeException("Unexpected Message Type");