mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Migrate away from placeholder revision to support exporting pending approval groups.
This commit is contained in:
committed by
Alex Hart
parent
dc8e93a9d3
commit
5ce5326721
@@ -1021,15 +1021,16 @@ final class GroupManagerV2 {
|
||||
/**
|
||||
* Creates a local group from what we know before joining.
|
||||
* <p>
|
||||
* Creates as a {@link GroupsV2StateProcessor#PLACEHOLDER_REVISION} so that we know not do do a
|
||||
* full diff against this group once we learn more about this group as that would create a large
|
||||
* update message.
|
||||
* Creates as a placeholder group so that we know not do do a full diff against this group once we learn more about this
|
||||
* group as that would create a large update message.
|
||||
*/
|
||||
private DecryptedGroup createPlaceholderGroup(@NonNull DecryptedGroupJoinInfo joinInfo, boolean requestToJoin) {
|
||||
DecryptedGroup.Builder group = new DecryptedGroup.Builder()
|
||||
.title(joinInfo.title)
|
||||
.avatar(joinInfo.avatar)
|
||||
.revision(GroupsV2StateProcessor.PLACEHOLDER_REVISION);
|
||||
.description(joinInfo.description)
|
||||
.revision(joinInfo.revision)
|
||||
.isPlaceholderGroup(true);
|
||||
|
||||
Recipient self = Recipient.self();
|
||||
ByteString selfAciBytes = selfAci.toByteString();
|
||||
|
||||
@@ -23,7 +23,6 @@ final class GroupStatePatcher {
|
||||
private static final String TAG = Log.tag(GroupStatePatcher.class);
|
||||
|
||||
static final int LATEST = Integer.MAX_VALUE;
|
||||
static final int PLACEHOLDER_REVISION = -1;
|
||||
static final int RESTORE_PLACEHOLDER_REVISION = -2;
|
||||
|
||||
private static final Comparator<DecryptedGroupChangeLog> BY_REVISION = (o1, o2) -> Integer.compare(o1.getRevision(), o2.getRevision());
|
||||
@@ -71,7 +70,7 @@ final class GroupStatePatcher {
|
||||
final int from = Math.max(0, inputState.getEarliestRevisionNumber());
|
||||
final int to = Math.min(inputState.getLatestRevisionNumber(), maximumRevisionToApply);
|
||||
|
||||
if (current != null && current.revision == PLACEHOLDER_REVISION) {
|
||||
if (current != null && current.isPlaceholderGroup) {
|
||||
Log.i(TAG, "Ignoring place holder group state");
|
||||
} else {
|
||||
stateChain.push(current, null);
|
||||
@@ -84,10 +83,11 @@ final class GroupStatePatcher {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stateChain.getLatestState() == null && entry.getGroup() != null && current != null && current.revision == PLACEHOLDER_REVISION) {
|
||||
if (stateChain.getLatestState() == null && entry.getGroup() != null && current != null && current.isPlaceholderGroup) {
|
||||
DecryptedGroup previousState = entry.getGroup().newBuilder()
|
||||
.title(current.title)
|
||||
.avatar(current.avatar)
|
||||
.description(current.description)
|
||||
.build();
|
||||
|
||||
stateChain.push(previousState, null);
|
||||
|
||||
@@ -70,12 +70,6 @@ class GroupsV2StateProcessor private constructor(
|
||||
|
||||
const val LATEST = GroupStatePatcher.LATEST
|
||||
|
||||
/**
|
||||
* Used to mark a group state as a placeholder when there is partial knowledge (title and avater)
|
||||
* gathered from a group join link.
|
||||
*/
|
||||
const val PLACEHOLDER_REVISION = GroupStatePatcher.PLACEHOLDER_REVISION
|
||||
|
||||
/**
|
||||
* Used to mark a group state as a placeholder when you have no knowledge at all of the group
|
||||
* e.g. from a group master key from a storage service restore.
|
||||
|
||||
Reference in New Issue
Block a user