Skip to content

Commit a66857a

Browse files
cody-signalnicholas-signal
authored andcommitted
Fix incorrect local group state bug.
1 parent 37815a3 commit a66857a

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V233_FixInAppPaymen
9494
import org.thoughtcrime.securesms.database.helpers.migration.V234_ThumbnailRestoreStateColumn
9595
import org.thoughtcrime.securesms.database.helpers.migration.V235_AttachmentUuidColumn
9696
import org.thoughtcrime.securesms.database.helpers.migration.V236_FixInAppSubscriberCurrencyIfAble
97+
import org.thoughtcrime.securesms.database.helpers.migration.V237_ResetGroupForceUpdateTimestamps
9798

9899
/**
99100
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
@@ -190,10 +191,11 @@ object SignalDatabaseMigrations {
190191
233 to V233_FixInAppPaymentTableDefaultNotifiedValue,
191192
234 to V234_ThumbnailRestoreStateColumn,
192193
235 to V235_AttachmentUuidColumn,
193-
236 to V236_FixInAppSubscriberCurrencyIfAble
194+
236 to V236_FixInAppSubscriberCurrencyIfAble,
195+
237 to V237_ResetGroupForceUpdateTimestamps
194196
)
195197

196-
const val DATABASE_VERSION = 236
198+
const val DATABASE_VERSION = 237
197199

198200
@JvmStatic
199201
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2024 Signal Messenger, LLC
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*/
5+
6+
package org.thoughtcrime.securesms.database.helpers.migration
7+
8+
import android.app.Application
9+
import net.zetetic.database.sqlcipher.SQLiteDatabase
10+
11+
/**
12+
* Reset last forced update timestamp for groups to fix a local group state bug.
13+
*/
14+
@Suppress("ClassName")
15+
object V237_ResetGroupForceUpdateTimestamps : SignalDatabaseMigration {
16+
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
17+
db.execSQL("UPDATE groups SET last_force_update_timestamp = 0")
18+
}
19+
}

app/src/main/java/org/thoughtcrime/securesms/groups/v2/processing/GroupsV2StateProcessor.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class GroupsV2StateProcessor private constructor(
158158
when (serverUpdateResult) {
159159
InternalUpdateResult.NoUpdateNeeded -> return GroupUpdateResult.CONSISTENT_OR_AHEAD
160160
is InternalUpdateResult.Updated -> return GroupUpdateResult.updated(serverUpdateResult.updatedLocalState)
161-
is InternalUpdateResult.UpdateFailed,
161+
is InternalUpdateResult.UpdateFailed -> throw serverUpdateResult.throwable
162162
is InternalUpdateResult.NotAMember -> Unit
163163
}
164164

@@ -184,11 +184,7 @@ class GroupsV2StateProcessor private constructor(
184184
profileAndMessageHelper.leaveGroupLocally(serviceIds)
185185
}
186186

187-
throw when (serverUpdateResult) {
188-
is InternalUpdateResult.NotAMember -> GroupNotAMemberException(serverUpdateResult.exception)
189-
is InternalUpdateResult.UpdateFailed -> throw serverUpdateResult.throwable
190-
else -> AssertionError("Should not reach here with ${serverUpdateResult::class.java.simpleName}")
191-
}
187+
throw GroupNotAMemberException(serverUpdateResult.exception)
192188
}
193189

194190
private fun canApplyP2pChange(

libsignal-service/src/main/java/org/whispersystems/signalservice/internal/push/PushServiceSocket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2921,7 +2921,7 @@ public int getGroupJoinedAtRevision(GroupsV2AuthorizationString authorization)
29212921
GROUPSV2_JOINED_AT,
29222922
"GET",
29232923
null,
2924-
NO_HANDLER))
2924+
GROUPS_V2_GET_CURRENT_HANDLER))
29252925
{
29262926
return Member.ADAPTER.decode(readBodyBytes(response)).joinedAtRevision;
29272927
}

0 commit comments

Comments
 (0)