Search in sources :

Example 1 with RequestGroupV2InfoJob

use of org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    // TODO [alex] LargeScreenSupport -- Remove these lines.
    WindowUtil.setLightNavigationBarFromTheme(requireActivity());
    WindowUtil.setLightStatusBarFromTheme(requireActivity());
    EventBus.getDefault().register(this);
    initializeMmsEnabledCheck();
    initializeIdentityRecords();
    composeText.setTransport(sendButton.getSelectedTransport());
    Recipient recipientSnapshot = recipient.get();
    titleView.setTitle(glideRequests, recipientSnapshot);
    setBlockedUserState(recipientSnapshot, isSecureText, isDefaultSms);
    calculateCharactersRemaining();
    if (recipientSnapshot.getGroupId().isPresent() && recipientSnapshot.getGroupId().get().isV2() && !recipientSnapshot.isBlocked()) {
        GroupId.V2 groupId = recipientSnapshot.getGroupId().get().requireV2();
        ApplicationDependencies.getJobManager().startChain(new RequestGroupV2InfoJob(groupId)).then(GroupV2UpdateSelfProfileKeyJob.withoutLimits(groupId)).enqueue();
        if (viewModel.getArgs().isFirstTimeInSelfCreatedGroup()) {
            groupViewModel.inviteFriendsOneTimeIfJustSelfInGroup(getChildFragmentManager(), groupId);
        }
    }
    if (groupCallViewModel != null) {
        groupCallViewModel.peekGroupCall();
    }
    setVisibleThread(threadId);
    ConversationUtil.refreshRecipientShortcuts();
    if (SignalStore.rateLimit().needsRecaptcha()) {
        RecaptchaProofBottomSheetFragment.show(getChildFragmentManager());
    }
}
Also used : LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) Recipient(org.thoughtcrime.securesms.recipients.Recipient) RequestGroupV2InfoJob(org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob) GroupId(org.thoughtcrime.securesms.groups.GroupId)

Example 2 with RequestGroupV2InfoJob

use of org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob in project Signal-Android by signalapp.

the class ConversationParentFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    // TODO [alex] LargeScreenSupport -- Remove these lines.
    WindowUtil.setLightNavigationBarFromTheme(requireActivity());
    WindowUtil.setLightStatusBarFromTheme(requireActivity());
    EventBus.getDefault().register(this);
    initializeMmsEnabledCheck();
    initializeIdentityRecords();
    composeText.setTransport(sendButton.getSelectedTransport());
    Recipient recipientSnapshot = recipient.get();
    titleView.setTitle(glideRequests, recipientSnapshot);
    setBlockedUserState(recipientSnapshot, isSecureText, isDefaultSms);
    calculateCharactersRemaining();
    if (recipientSnapshot.getGroupId().isPresent() && recipientSnapshot.getGroupId().get().isV2() && !recipientSnapshot.isBlocked()) {
        GroupId.V2 groupId = recipientSnapshot.getGroupId().get().requireV2();
        ApplicationDependencies.getJobManager().startChain(new RequestGroupV2InfoJob(groupId)).then(GroupV2UpdateSelfProfileKeyJob.withoutLimits(groupId)).enqueue();
        if (viewModel.getArgs().isFirstTimeInSelfCreatedGroup()) {
            groupViewModel.inviteFriendsOneTimeIfJustSelfInGroup(getChildFragmentManager(), groupId);
        }
    }
    if (groupCallViewModel != null) {
        groupCallViewModel.peekGroupCall();
    }
    setVisibleThread(threadId);
    ConversationUtil.refreshRecipientShortcuts();
    if (SignalStore.rateLimit().needsRecaptcha()) {
        RecaptchaProofBottomSheetFragment.show(getChildFragmentManager());
    }
}
Also used : LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) Recipient(org.thoughtcrime.securesms.recipients.Recipient) RequestGroupV2InfoJob(org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob) GroupId(org.thoughtcrime.securesms.groups.GroupId)

Example 3 with RequestGroupV2InfoJob

use of org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob in project Signal-Android by signalapp.

the class GroupDatabase method fixMissingMasterKey.

/**
 * There was a point in time where we weren't properly responding to group creates on linked devices. This would result in us having a Recipient entry for the
 * group, but we'd either be missing the group entry, or that entry would be missing a master key. This method fixes this scenario.
 */
public void fixMissingMasterKey(@NonNull GroupMasterKey groupMasterKey) {
    GroupId.V2 groupId = GroupId.v2(groupMasterKey);
    if (getGroupV1ByExpectedV2(groupId).isPresent()) {
        Log.w(TAG, "There already exists a V1 group that should be migrated into this group. But if the recipient already exists, there's not much we can do here.");
    }
    SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
    db.beginTransaction();
    try {
        String query = GROUP_ID + " = ?";
        String[] args = SqlUtil.buildArgs(groupId);
        ContentValues values = new ContentValues();
        values.put(V2_MASTER_KEY, groupMasterKey.serialize());
        int updated = db.update(TABLE_NAME, values, query, args);
        if (updated < 1) {
            Log.w(TAG, "No group entry. Creating restore placeholder for " + groupId);
            create(groupMasterKey, DecryptedGroup.newBuilder().setRevision(GroupsV2StateProcessor.RESTORE_PLACEHOLDER_REVISION).build(), true);
        } else {
            Log.w(TAG, "Had a group entry, but it was missing a master key. Updated.");
        }
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
    Log.w(TAG, "Scheduling request for latest group info for " + groupId);
    ApplicationDependencies.getJobManager().add(new RequestGroupV2InfoJob(groupId));
}
Also used : ContentValues(android.content.ContentValues) RequestGroupV2InfoJob(org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob) SuppressLint(android.annotation.SuppressLint) GroupId(org.thoughtcrime.securesms.groups.GroupId)

Example 4 with RequestGroupV2InfoJob

use of org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob in project Signal-Android by WhisperSystems.

the class GroupDatabase method fixMissingMasterKey.

/**
 * There was a point in time where we weren't properly responding to group creates on linked devices. This would result in us having a Recipient entry for the
 * group, but we'd either be missing the group entry, or that entry would be missing a master key. This method fixes this scenario.
 */
public void fixMissingMasterKey(@NonNull GroupMasterKey groupMasterKey) {
    GroupId.V2 groupId = GroupId.v2(groupMasterKey);
    if (getGroupV1ByExpectedV2(groupId).isPresent()) {
        Log.w(TAG, "There already exists a V1 group that should be migrated into this group. But if the recipient already exists, there's not much we can do here.");
    }
    SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
    db.beginTransaction();
    try {
        String query = GROUP_ID + " = ?";
        String[] args = SqlUtil.buildArgs(groupId);
        ContentValues values = new ContentValues();
        values.put(V2_MASTER_KEY, groupMasterKey.serialize());
        int updated = db.update(TABLE_NAME, values, query, args);
        if (updated < 1) {
            Log.w(TAG, "No group entry. Creating restore placeholder for " + groupId);
            create(groupMasterKey, DecryptedGroup.newBuilder().setRevision(GroupsV2StateProcessor.RESTORE_PLACEHOLDER_REVISION).build(), true);
        } else {
            Log.w(TAG, "Had a group entry, but it was missing a master key. Updated.");
        }
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
    Log.w(TAG, "Scheduling request for latest group info for " + groupId);
    ApplicationDependencies.getJobManager().add(new RequestGroupV2InfoJob(groupId));
}
Also used : ContentValues(android.content.ContentValues) RequestGroupV2InfoJob(org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob) SuppressLint(android.annotation.SuppressLint) GroupId(org.thoughtcrime.securesms.groups.GroupId)

Aggregations

GroupId (org.thoughtcrime.securesms.groups.GroupId)4 RequestGroupV2InfoJob (org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob)4 SuppressLint (android.annotation.SuppressLint)2 ContentValues (android.content.ContentValues)2 LiveRecipient (org.thoughtcrime.securesms.recipients.LiveRecipient)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2