Merge branch '732-reveal-contacts-ui-join-notices' into 'master'

Add visibility and OPTIONS button to private group join notices

![device-2016-11-11-180658](/uploads/e00d175a1e1f34307c5f0d80fa0d1cdf/device-2016-11-11-180658.png)
![device-2016-11-11-181325](/uploads/0f6010094d529a4f151db8ebce974885/device-2016-11-11-181325.png)

Closes #732

See merge request !408
This commit is contained in:
akwizgran
2016-11-16 13:44:32 +00:00
24 changed files with 400 additions and 151 deletions

View File

@@ -13,6 +13,7 @@ interface GroupConstants {
String KEY_MEMBER_ID = "memberId";
String KEY_MEMBER_NAME = "memberName";
String KEY_MEMBER_PUBLIC_KEY = "memberPublicKey";
String KEY_INITIAL_JOIN_MSG = "initialJoinMsg";
String GROUP_KEY_MEMBERS = "members";
String GROUP_KEY_OUR_GROUP = "ourGroup";

View File

@@ -29,6 +29,7 @@ import static org.briarproject.api.identity.AuthorConstants.MAX_SIGNATURE_LENGTH
import static org.briarproject.api.privategroup.MessageType.JOIN;
import static org.briarproject.api.privategroup.MessageType.POST;
import static org.briarproject.api.privategroup.PrivateGroupConstants.MAX_GROUP_POST_BODY_LENGTH;
import static org.briarproject.privategroup.GroupConstants.KEY_INITIAL_JOIN_MSG;
import static org.briarproject.privategroup.GroupConstants.KEY_MEMBER_ID;
import static org.briarproject.privategroup.GroupConstants.KEY_MEMBER_NAME;
import static org.briarproject.privategroup.GroupConstants.KEY_MEMBER_PUBLIC_KEY;
@@ -99,10 +100,12 @@ class GroupMessageValidator extends BdfMessageValidator {
// invite is null if the member is the creator of the private group
Author creator = pg.getCreator();
boolean isCreator = false;
BdfList invite = body.getOptionalList(3);
if (invite == null) {
if (!member.equals(creator))
throw new InvalidMessageException();
isCreator = true;
} else {
if (member.equals(creator))
throw new InvalidMessageException();
@@ -149,6 +152,7 @@ class GroupMessageValidator extends BdfMessageValidator {
// Return the metadata and no dependencies
BdfDictionary meta = new BdfDictionary();
meta.put(KEY_INITIAL_JOIN_MSG, isCreator);
return new BdfMessageContext(meta);
}

View File

@@ -60,6 +60,7 @@ import static org.briarproject.privategroup.GroupConstants.GROUP_KEY_DISSOLVED;
import static org.briarproject.privategroup.GroupConstants.GROUP_KEY_MEMBERS;
import static org.briarproject.privategroup.GroupConstants.GROUP_KEY_OUR_GROUP;
import static org.briarproject.privategroup.GroupConstants.GROUP_KEY_VISIBILITY;
import static org.briarproject.privategroup.GroupConstants.KEY_INITIAL_JOIN_MSG;
import static org.briarproject.privategroup.GroupConstants.KEY_MEMBER_ID;
import static org.briarproject.privategroup.GroupConstants.KEY_MEMBER_NAME;
import static org.briarproject.privategroup.GroupConstants.KEY_MEMBER_PUBLIC_KEY;
@@ -114,16 +115,17 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
new BdfEntry(GROUP_KEY_DISSOLVED, false)
);
clientHelper.mergeGroupMetadata(txn, group.getId(), meta);
joinPrivateGroup(txn, joinMsg);
joinPrivateGroup(txn, joinMsg, creator);
} catch (FormatException e) {
throw new DbException(e);
}
}
private void joinPrivateGroup(Transaction txn, GroupMessage m)
throws DbException, FormatException {
private void joinPrivateGroup(Transaction txn, GroupMessage m,
boolean creator) throws DbException, FormatException {
BdfDictionary meta = new BdfDictionary();
meta.put(KEY_TYPE, JOIN.getInt());
meta.put(KEY_INITIAL_JOIN_MSG, creator);
addMessageMetadata(meta, m, true);
clientHelper.addLocalMessage(txn, m.getMessage(), meta, true);
trackOutgoingMessage(txn, m.getMessage());
@@ -377,7 +379,8 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
GroupMessageHeader header =
getGroupMessageHeader(txn, g, id, meta, statuses);
return new JoinMessageHeader(header, v);
boolean creator = meta.getBoolean(KEY_INITIAL_JOIN_MSG);
return new JoinMessageHeader(header, v, creator);
}
@Override
@@ -451,7 +454,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
if (!foundMember) throw new ProtocolStateException();
if (changed) {
clientHelper.mergeGroupMetadata(txn, g, meta);
txn.attach(new ContactRelationshipRevealedEvent(g, v));
txn.attach(new ContactRelationshipRevealedEvent(g, a, v));
}
}