Search in sources :

Example 1 with DecryptedModifyMemberRole

use of org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole in project Signal-Android by WhisperSystems.

the class DecryptedGroupUtil method applyModifyMemberRoleActions.

private static void applyModifyMemberRoleActions(DecryptedGroup.Builder builder, List<DecryptedModifyMemberRole> modifyMemberRolesList) throws NotAbleToApplyGroupV2ChangeException {
    for (DecryptedModifyMemberRole modifyMemberRole : modifyMemberRolesList) {
        int index = indexOfUuid(builder.getMembersList(), modifyMemberRole.getUuid());
        if (index == -1) {
            throw new NotAbleToApplyGroupV2ChangeException();
        }
        Member.Role role = modifyMemberRole.getRole();
        ensureKnownRole(role);
        builder.setMembers(index, DecryptedMember.newBuilder(builder.getMembers(index)).setRole(role));
    }
}
Also used : DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) Member(org.signal.storageservice.protos.groups.Member) DecryptedApproveMember(org.signal.storageservice.protos.groups.local.DecryptedApproveMember) DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) DecryptedModifyMemberRole(org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole)

Example 2 with DecryptedModifyMemberRole

use of org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole in project Signal-Android by WhisperSystems.

the class GroupChangeUtil method resolveField5ModifyMemberRoles.

private static void resolveField5ModifyMemberRoles(DecryptedGroupChange conflictingChange, ChangeSetModifier result, HashMap<ByteString, DecryptedMember> fullMembersByUuid) {
    List<DecryptedModifyMemberRole> modifyRolesList = conflictingChange.getModifyMemberRolesList();
    for (int i = modifyRolesList.size() - 1; i >= 0; i--) {
        DecryptedModifyMemberRole modifyRoleAction = modifyRolesList.get(i);
        DecryptedMember memberInGroup = fullMembersByUuid.get(modifyRoleAction.getUuid());
        if (memberInGroup == null || memberInGroup.getRole() == modifyRoleAction.getRole()) {
            result.removeModifyMemberRoles(i);
        }
    }
}
Also used : DecryptedModifyMemberRole(org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember)

Aggregations

DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)2 DecryptedModifyMemberRole (org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole)2 Member (org.signal.storageservice.protos.groups.Member)1 DecryptedApproveMember (org.signal.storageservice.protos.groups.local.DecryptedApproveMember)1 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)1 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)1