mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 09:18:49 +00:00
Cleanup some possible bad RecipientIds in the MMS table.
This commit is contained in:
parent
daeb823399
commit
4b3d129097
@ -85,8 +85,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
private static final int ATTACHMENT_HASHING = 28;
|
private static final int ATTACHMENT_HASHING = 28;
|
||||||
private static final int NOTIFICATION_RECIPIENT_IDS = 29;
|
private static final int NOTIFICATION_RECIPIENT_IDS = 29;
|
||||||
private static final int BLUR_HASH = 30;
|
private static final int BLUR_HASH = 30;
|
||||||
|
private static final int MMS_RECIPIENT_CLEANUP_2 = 31;
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 30;
|
private static final int DATABASE_VERSION = 31;
|
||||||
private static final String DATABASE_NAME = "signal.db";
|
private static final String DATABASE_NAME = "signal.db";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@ -589,6 +590,13 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL("ALTER TABLE part ADD COLUMN blur_hash TEXT DEFAULT NULL");
|
db.execSQL("ALTER TABLE part ADD COLUMN blur_hash TEXT DEFAULT NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < MMS_RECIPIENT_CLEANUP_2) {
|
||||||
|
ContentValues values = new ContentValues(1);
|
||||||
|
values.put("address", "-1");
|
||||||
|
int count = db.update("mms", values, "address = ? OR address IS NULL", new String[] { "0" });
|
||||||
|
Log.i(TAG, "MMS recipient cleanup 2 updated " + count + " rows.");
|
||||||
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
|
@ -24,14 +24,18 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
|||||||
|
|
||||||
public static RecipientId from(long id) {
|
public static RecipientId from(long id) {
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
throw new AssertionError("Invalid ID!");
|
throw new InvalidLongRecipientIdError();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RecipientId(id);
|
return new RecipientId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RecipientId from(@NonNull String id) {
|
public static RecipientId from(@NonNull String id) {
|
||||||
|
try {
|
||||||
return RecipientId.from(Long.parseLong(id));
|
return RecipientId.from(Long.parseLong(id));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new InvalidStringRecipientIdError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RecipientId(long id) {
|
private RecipientId(long id) {
|
||||||
@ -116,4 +120,7 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
|||||||
return new RecipientId[size];
|
return new RecipientId[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static class InvalidLongRecipientIdError extends AssertionError {}
|
||||||
|
private static class InvalidStringRecipientIdError extends AssertionError {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user