mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Do not bump group threads on leave.
This commit is contained in:
committed by
Greyson Parrelli
parent
ee548d27e5
commit
5649c906a5
@@ -1,7 +1,11 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroupChange;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
||||
import org.thoughtcrime.securesms.mms.MessageGroupContext;
|
||||
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil;
|
||||
|
||||
import static org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
||||
|
||||
@@ -39,4 +43,28 @@ public final class IncomingGroupUpdateMessage extends IncomingTextMessage {
|
||||
return !groupContext.isV2Group() && groupContext.requireGroupV1Properties().isQuit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJustAGroupLeave() {
|
||||
if (isGroupV2() && isUpdate()) {
|
||||
DecryptedGroupChange decryptedGroupChange = groupContext.requireGroupV2Properties()
|
||||
.getChange();
|
||||
|
||||
return changeEditorOnlyWasRemoved(decryptedGroupChange) &&
|
||||
noChangesOtherThanDeletes(decryptedGroupChange);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean changeEditorOnlyWasRemoved(@NonNull DecryptedGroupChange decryptedGroupChange) {
|
||||
return decryptedGroupChange.getDeleteMembersCount() == 1 &&
|
||||
decryptedGroupChange.getDeleteMembers(0).equals(decryptedGroupChange.getEditor());
|
||||
}
|
||||
|
||||
protected boolean noChangesOtherThanDeletes(@NonNull DecryptedGroupChange decryptedGroupChange) {
|
||||
DecryptedGroupChange withoutDeletedMembers = decryptedGroupChange.toBuilder()
|
||||
.clearDeleteMembers()
|
||||
.build();
|
||||
return DecryptedGroupUtil.changeIsEmpty(withoutDeletedMembers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,13 @@ public class IncomingTextMessage implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True iff the message is only a group leave of a single member.
|
||||
*/
|
||||
public boolean isJustAGroupLeave() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUnidentified() {
|
||||
return unidentified;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user