mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:13:57 +00:00
Skip drafts and outbox messages during imports.
// FREEBIE Closes #1468 Fixes #892
This commit is contained in:
parent
188d11bc23
commit
d7de5415b5
@ -196,8 +196,10 @@ public interface MmsSmsColumns {
|
||||
switch ((int)theirType) {
|
||||
case 1: return BASE_INBOX_TYPE;
|
||||
case 2: return BASE_SENT_TYPE;
|
||||
case 3: return BASE_DRAFT_TYPE;
|
||||
case 4: return BASE_OUTBOX_TYPE;
|
||||
case 5: return BASE_SENT_FAILED_TYPE;
|
||||
case 6: return BASE_OUTBOX_TYPE;
|
||||
}
|
||||
|
||||
return BASE_INBOX_TYPE;
|
||||
|
@ -63,6 +63,9 @@ public class PlaintextBackupImporter {
|
||||
if (item.getAddress() == null || item.getAddress().equals("null"))
|
||||
continue;
|
||||
|
||||
if (!isAppropriateTypeForImport(item.getType()))
|
||||
continue;
|
||||
|
||||
addStringToStatement(statement, 1, item.getAddress());
|
||||
addNullToStatement(statement, 2);
|
||||
addLongToStatement(statement, 3, item.getDate());
|
||||
@ -121,4 +124,13 @@ public class PlaintextBackupImporter {
|
||||
statement.bindLong(index, value);
|
||||
}
|
||||
|
||||
private static boolean isAppropriateTypeForImport(long theirType) {
|
||||
long ourType = SmsDatabase.Types.translateFromSystemBaseType(theirType);
|
||||
|
||||
return ourType == MmsSmsColumns.Types.BASE_INBOX_TYPE ||
|
||||
ourType == MmsSmsColumns.Types.BASE_SENT_TYPE ||
|
||||
ourType == MmsSmsColumns.Types.BASE_SENT_FAILED_TYPE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -83,6 +83,15 @@ public class SmsMigrator {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAppropriateTypeForMigration(Cursor cursor, int columnIndex) {
|
||||
long systemType = cursor.getLong(columnIndex);
|
||||
long ourType = SmsDatabase.Types.translateFromSystemBaseType(systemType);
|
||||
|
||||
return ourType == MmsSmsColumns.Types.BASE_INBOX_TYPE ||
|
||||
ourType == MmsSmsColumns.Types.BASE_SENT_TYPE ||
|
||||
ourType == MmsSmsColumns.Types.BASE_SENT_FAILED_TYPE;
|
||||
}
|
||||
|
||||
private static void getContentValuesForRow(Context context, MasterSecret masterSecret,
|
||||
Cursor cursor, long threadId,
|
||||
SQLiteStatement statement)
|
||||
@ -171,8 +180,12 @@ public class SmsMigrator {
|
||||
SQLiteStatement statement = ourSmsDatabase.createInsertStatement(transaction);
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
getContentValuesForRow(context, masterSecret, cursor, ourThreadId, statement);
|
||||
statement.execute();
|
||||
int typeColumn = cursor.getColumnIndex(SmsDatabase.TYPE);
|
||||
|
||||
if (cursor.isNull(typeColumn) || isAppropriateTypeForMigration(cursor, typeColumn)) {
|
||||
getContentValuesForRow(context, masterSecret, cursor, ourThreadId, statement);
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
listener.progressUpdate(new ProgressDescription(progress, cursor.getCount(), cursor.getPosition()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user