Add client version to groups table.

This commit is contained in:
akwizgran
2018-04-13 13:10:02 +01:00
parent a38f39207f
commit 8c00f2417b
23 changed files with 116 additions and 67 deletions

View File

@@ -241,7 +241,8 @@ public interface DatabaseComponent {
* <p/>
* Read-only.
*/
Collection<Group> getGroups(Transaction txn, ClientId c) throws DbException;
Collection<Group> getGroups(Transaction txn, ClientId c, int clientVersion)
throws DbException;
/**
* Returns the given group's visibility to the given contact, or

View File

@@ -17,13 +17,16 @@ public class Group {
private final GroupId id;
private final ClientId clientId;
private final int clientVersion;
private final byte[] descriptor;
public Group(GroupId id, ClientId clientId, byte[] descriptor) {
public Group(GroupId id, ClientId clientId, int clientVersion,
byte[] descriptor) {
if (descriptor.length > MAX_GROUP_DESCRIPTOR_LENGTH)
throw new IllegalArgumentException();
this.id = id;
this.clientId = clientId;
this.clientVersion = clientVersion;
this.descriptor = descriptor;
}
@@ -41,6 +44,13 @@ public class Group {
return clientId;
}
/**
* Returns the version of the client to which the group belongs.
*/
public int getClientVersion() {
return clientVersion;
}
/**
* Returns the group's descriptor.
*/

View File

@@ -117,15 +117,16 @@ public class TestUtils {
return new Author(id, FORMAT_VERSION, name, publicKey);
}
public static Group getGroup(ClientId clientId) {
public static Group getGroup(ClientId clientId, int clientVersion) {
int descriptorLength = 1 + random.nextInt(MAX_GROUP_DESCRIPTOR_LENGTH);
return getGroup(clientId, descriptorLength);
return getGroup(clientId, clientVersion, descriptorLength);
}
public static Group getGroup(ClientId clientId, int descriptorLength) {
public static Group getGroup(ClientId clientId, int clientVersion,
int descriptorLength) {
GroupId groupId = new GroupId(getRandomId());
byte[] descriptor = getRandomBytes(descriptorLength);
return new Group(groupId, clientId, descriptor);
return new Group(groupId, clientId, clientVersion, descriptor);
}
public static Message getMessage(GroupId groupId) {