use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.
the class GroupsV2Operations_decrypt_group_Test method decrypt_description_field_11.
@Test
public void decrypt_description_field_11() throws VerificationFailedException, InvalidGroupStateException {
Group group = Group.newBuilder().setDescription(groupOperations.encryptDescription("Description!")).build();
DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
assertEquals("Description!", decryptedGroup.getDescription());
}
use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.
the class GroupsV2Operations_decrypt_group_Test method avatar_field_passed_through_3.
@Test
public void avatar_field_passed_through_3() throws VerificationFailedException, InvalidGroupStateException {
Group group = Group.newBuilder().setAvatar("AvatarCdnKey").build();
DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
assertEquals("AvatarCdnKey", decryptedGroup.getAvatar());
}
use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.
the class GroupsV2Operations_decrypt_group_Test method pass_through_access_control_field_5.
@Test
public void pass_through_access_control_field_5() throws VerificationFailedException, InvalidGroupStateException {
AccessControl accessControl = AccessControl.newBuilder().setMembers(AccessControl.AccessRequired.ADMINISTRATOR).setAttributes(AccessControl.AccessRequired.MEMBER).setAddFromInviteLink(AccessControl.AccessRequired.UNSATISFIABLE).build();
Group group = Group.newBuilder().setAccessControl(accessControl).build();
DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
assertEquals(accessControl, decryptedGroup.getAccessControl());
}
use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.
the class GroupsV2Api method putNewGroup.
public void putNewGroup(GroupsV2Operations.NewGroup newGroup, GroupsV2AuthorizationString authorization) throws IOException {
Group group = newGroup.getNewGroupMessage();
if (newGroup.getAvatar().isPresent()) {
String cdnKey = uploadAvatar(newGroup.getAvatar().get(), newGroup.getGroupSecretParams(), authorization);
group = Group.newBuilder(group).setAvatar(cdnKey).build();
}
socket.putNewGroupsV2Group(group, authorization);
}
use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.
the class GroupsV2Operations method createNewGroup.
/**
* Creates a new group with the title and avatar.
*
* @param self You will be member 0 and the only admin.
* @param members Members must not contain self. Members will be non-admin members of the group.
*/
public NewGroup createNewGroup(final GroupSecretParams groupSecretParams, final String title, final Optional<byte[]> avatar, final GroupCandidate self, final Set<GroupCandidate> members, final Member.Role memberRole, final int disappearingMessageTimerSeconds) {
if (members.contains(self)) {
throw new IllegalArgumentException("Members must not contain self");
}
final GroupOperations groupOperations = forGroup(groupSecretParams);
Group.Builder group = Group.newBuilder().setRevision(0).setPublicKey(ByteString.copyFrom(groupSecretParams.getPublicParams().serialize())).setTitle(groupOperations.encryptTitle(title)).setDisappearingMessagesTimer(groupOperations.encryptTimer(disappearingMessageTimerSeconds)).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.MEMBER).setMembers(AccessControl.AccessRequired.MEMBER));
group.addMembers(groupOperations.member(self.getProfileKeyCredential().get(), Member.Role.ADMINISTRATOR));
for (GroupCandidate credential : members) {
ProfileKeyCredential profileKeyCredential = credential.getProfileKeyCredential().orNull();
if (profileKeyCredential != null) {
group.addMembers(groupOperations.member(profileKeyCredential, memberRole));
} else {
group.addPendingMembers(groupOperations.invitee(credential.getUuid(), memberRole));
}
}
return new NewGroup(groupSecretParams, group.build(), avatar);
}
Aggregations