Skip to content

Commit

Permalink
Fix open group polling from seqno instead of last hash (#939)
Browse files Browse the repository at this point in the history
* fix: reset seqno to get recent messages from open groups

* build: upgrade build numbers

* fix: actually run the migration
  • Loading branch information
hjubb authored Aug 15, 2022
1 parent 7dcb566 commit c65feba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.4'
}

def canonicalVersionCode = 292
def canonicalVersionName = "1.14.0"
def canonicalVersionCode = 293
def canonicalVersionName = "1.14.1"

def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
private val token = "token"
@JvmStatic val createOpenGroupAuthTokenTableCommand = "CREATE TABLE $openGroupAuthTokenTable ($server TEXT PRIMARY KEY, $token TEXT);"
// Last message server IDs
private val lastMessageServerIDTable = "loki_api_last_message_server_id_cache"
private const val lastMessageServerIDTable = "loki_api_last_message_server_id_cache"
private val lastMessageServerIDTableIndex = "loki_api_last_message_server_id_cache_index"
private val lastMessageServerID = "last_message_server_id"
private const val lastMessageServerID = "last_message_server_id"
@JvmStatic val createLastMessageServerIDTableCommand = "CREATE TABLE $lastMessageServerIDTable ($lastMessageServerIDTableIndex STRING PRIMARY KEY, $lastMessageServerID INTEGER DEFAULT 0);"
// Last deletion server IDs
private val lastDeletionServerIDTable = "loki_api_last_deletion_server_id_cache"
Expand Down Expand Up @@ -153,6 +153,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
"$requestSignature STRING NULLABLE DEFAULT NULL, $authorizationSignature STRING NULLABLE DEFAULT NULL, PRIMARY KEY ($masterPublicKey, $slavePublicKey));"
private val sessionRequestTimestampCache = "session_request_timestamp_cache"
@JvmStatic val createSessionRequestTimestampCacheCommand = "CREATE TABLE $sessionRequestTimestampCache ($publicKey STRING PRIMARY KEY, $timestamp STRING);"

const val RESET_SEQ_NO = "UPDATE $lastMessageServerIDTable SET $lastMessageServerID = 0;"

// endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV33 = 54;
private static final int lokiV34 = 55;
private static final int lokiV35 = 56;
private static final int lokiV36 = 57;

// Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final int DATABASE_VERSION = lokiV35;
private static final int DATABASE_VERSION = lokiV36;
private static final String DATABASE_NAME = "signal.db";

private final Context context;
Expand Down Expand Up @@ -169,6 +170,7 @@ public void onCreate(SQLiteDatabase db) {
db.execSQL(LokiAPIDatabase.DROP_LEGACY_RECEIVED_HASHES);
db.execSQL(BlindedIdMappingDatabase.CREATE_BLINDED_ID_MAPPING_TABLE_COMMAND);
db.execSQL(GroupMemberDatabase.CREATE_GROUP_MEMBER_TABLE_COMMAND);
db.execSQL(LokiAPIDatabase.RESET_SEQ_NO); // probably not needed but consistent with all migrations

executeStatements(db, SmsDatabase.CREATE_INDEXS);
executeStatements(db, MmsDatabase.CREATE_INDEXS);
Expand Down Expand Up @@ -385,6 +387,10 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(GroupMemberDatabase.CREATE_GROUP_MEMBER_TABLE_COMMAND);
}

if (oldVersion < lokiV36) {
db.execSQL(LokiAPIDatabase.RESET_SEQ_NO);
}

db.setTransactionSuccessful();
} finally {
db.endTransaction();
Expand Down

0 comments on commit c65feba

Please sign in to comment.