Search in sources :

Example 1 with GroupsV2StateProcessor

use of org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor in project Signal-Android by WhisperSystems.

the class GroupManagerV2 method addedGroupVersion.

@WorkerThread
@NonNull
DecryptedGroup addedGroupVersion(@NonNull GroupMasterKey groupMasterKey) throws GroupNotAMemberException, IOException, GroupDoesNotExistException {
    GroupsV2StateProcessor.StateProcessorForGroup stateProcessorForGroup = new GroupsV2StateProcessor(context).forGroup(groupMasterKey);
    DecryptedGroup latest = stateProcessorForGroup.getCurrentGroupStateFromServer();
    if (latest.getRevision() == 0) {
        return latest;
    }
    Optional<DecryptedMember> selfInFullMemberList = DecryptedGroupUtil.findMemberByUuid(latest.getMembersList(), selfAci.uuid());
    if (!selfInFullMemberList.isPresent()) {
        return latest;
    }
    DecryptedGroup joinedVersion = stateProcessorForGroup.getSpecificVersionFromServer(selfInFullMemberList.get().getJoinedAtRevision());
    if (joinedVersion != null) {
        return joinedVersion;
    } else {
        Log.w(TAG, "Unable to retreive exact version joined at, using latest");
        return latest;
    }
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) GroupsV2StateProcessor(org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1 WorkerThread (androidx.annotation.WorkerThread)1 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)1 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)1 GroupsV2StateProcessor (org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor)1