Promptly remove terminated groups from shortcuts.

This commit is contained in:
Cody Henthorne
2026-04-13 12:01:00 -04:00
committed by jeffrey-signal
parent 3c68e29679
commit 7aadc208e1
3 changed files with 19 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.database.model.GroupRecord;
import org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl;
import org.thoughtcrime.securesms.groups.v2.GroupLinkPassword;
import org.thoughtcrime.securesms.groups.v2.processing.GroupUpdateResult;
import org.thoughtcrime.securesms.jobs.ConversationShortcutUpdateJob;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
@@ -82,6 +83,7 @@ public final class GroupManager {
try (GroupManagerV2.GroupEditor edit = new GroupManagerV2(context).edit(groupId.requireV2())) {
edit.terminateGroup();
SignalDatabase.groups().setTerminatedBy(groupId, Recipient.self().getId());
ConversationShortcutUpdateJob.enqueue();
Log.i(TAG, "Terminated group " + groupId);
} catch (GroupInsufficientRightsException e) {
Log.w(TAG, "Insufficient rights to terminate " + groupId, e);

View File

@@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.groups.GroupProtoUtil
import org.thoughtcrime.securesms.groups.v2.ProfileKeySet
import org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor.Companion.LATEST
import org.thoughtcrime.securesms.jobs.AvatarGroupsV2DownloadJob
import org.thoughtcrime.securesms.jobs.ConversationShortcutUpdateJob
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob
import org.thoughtcrime.securesms.jobs.LeaveGroupV2Job
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob
@@ -543,7 +544,8 @@ class GroupsV2StateProcessor private constructor(
Log.i(TAG, "$logPrefix Local state (revision: ${currentLocalState?.revision}) does not match, updating to ${updatedGroupState.revision}")
}
val terminatorRecipientId: RecipientId? = if (updatedGroupState.terminated && (currentLocalState == null || !currentLocalState.terminated)) {
val wasTerminated = updatedGroupState.terminated && (currentLocalState == null || !currentLocalState.terminated)
val terminatorRecipientId: RecipientId? = if (wasTerminated) {
groupStateDiff.serverHistory
.mapNotNull { it.change }
.firstOrNull { it.terminateGroup }
@@ -559,6 +561,10 @@ class GroupsV2StateProcessor private constructor(
profileAndMessageHelper.stopAllTypingForGroup()
}
if (wasTerminated) {
ConversationShortcutUpdateJob.enqueue()
}
if (currentLocalState == null || currentLocalState.revision == RESTORE_PLACEHOLDER_REVISION) {
if (!updatedGroupState.terminated) {
Log.i(TAG, "$logPrefix Inserting single update message for no local state or restore placeholder")
@@ -787,6 +793,7 @@ class GroupsV2StateProcessor private constructor(
}
SignalDatabase.groups.update(masterKey, simulatedGroupState, null)
ConversationShortcutUpdateJob.enqueue()
}
fun markJoinRequestRejectedLocally() {