kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add explicit exceptions and group_type correction.
rodzic
539cd4059d
commit
1b053a2613
|
@ -599,7 +599,7 @@ class DistributionListDatabase constructor(context: Context?, databaseHelper: Si
|
||||||
SignalDatabase.recipients.updateStorageId(recipientId, update.new.id.raw)
|
SignalDatabase.recipients.updateStorageId(recipientId, update.new.id.raw)
|
||||||
|
|
||||||
if (update.new.deletedAtTimestamp > 0L) {
|
if (update.new.deletedAtTimestamp > 0L) {
|
||||||
if (distributionId.asUuid().equals(DistributionId.MY_STORY.asUuid())) {
|
if (distributionId == DistributionId.MY_STORY) {
|
||||||
Log.w(TAG, "Refusing to delete My Story.")
|
Log.w(TAG, "Refusing to delete My Story.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,8 +207,9 @@ object SignalDatabaseMigrations {
|
||||||
private const val EXPIRING_PROFILE_CREDENTIALS = 149
|
private const val EXPIRING_PROFILE_CREDENTIALS = 149
|
||||||
private const val URGENT_FLAG = 150
|
private const val URGENT_FLAG = 150
|
||||||
private const val MY_STORY_MIGRATION = 151
|
private const val MY_STORY_MIGRATION = 151
|
||||||
|
private const val STORY_GROUP_TYPES = 152
|
||||||
|
|
||||||
const val DATABASE_VERSION = 151
|
const val DATABASE_VERSION = 152
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||||
|
@ -2675,6 +2676,16 @@ object SignalDatabaseMigrations {
|
||||||
if (oldVersion < MY_STORY_MIGRATION) {
|
if (oldVersion < MY_STORY_MIGRATION) {
|
||||||
MyStoryMigration.migrate(context, db, oldVersion, newVersion)
|
MyStoryMigration.migrate(context, db, oldVersion, newVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < STORY_GROUP_TYPES) {
|
||||||
|
db.execSQL(
|
||||||
|
"""
|
||||||
|
UPDATE recipient
|
||||||
|
SET group_type = 4
|
||||||
|
WHERE distribution_list_id IS NOT NULL
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -5,6 +5,7 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.signal.core.util.StringUtil;
|
import org.signal.core.util.StringUtil;
|
||||||
import org.signal.core.util.logging.Log;
|
import org.signal.core.util.logging.Log;
|
||||||
|
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.RecipientRecord;
|
import org.thoughtcrime.securesms.database.model.RecipientRecord;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
|
@ -75,7 +76,16 @@ public class StoryDistributionListRecordProcessor extends DefaultStorageRecordPr
|
||||||
throw new IllegalStateException("Found matching recipient but couldn't generate record for sync.");
|
throw new IllegalStateException("Found matching recipient but couldn't generate record for sync.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return StorageSyncModels.localToRemoteRecord(recordForSync).getStoryDistributionList();
|
if (recordForSync.getGroupType().getId() != RecipientDatabase.GroupType.DISTRIBUTION_LIST.getId()) {
|
||||||
|
throw new InvalidGroupTypeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<SignalStoryDistributionListRecord> record = StorageSyncModels.localToRemoteRecord(recordForSync).getStoryDistributionList();
|
||||||
|
if (record.isPresent()) {
|
||||||
|
return record;
|
||||||
|
} else {
|
||||||
|
throw new UnexpectedEmptyOptionalException();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -145,4 +155,16 @@ public class StoryDistributionListRecordProcessor extends DefaultStorageRecordPr
|
||||||
allowsReplies == record.allowsReplies() &&
|
allowsReplies == record.allowsReplies() &&
|
||||||
isBlockList == record.isBlockList();
|
isBlockList == record.isBlockList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when the RecipientSettings object for a given distribution list is not the
|
||||||
|
* correct group type (4).
|
||||||
|
*/
|
||||||
|
private static class InvalidGroupTypeException extends RuntimeException {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when the distribution list object returned from the storage sync helper is
|
||||||
|
* absent, even though a RecipientSettings was found.
|
||||||
|
*/
|
||||||
|
private static class UnexpectedEmptyOptionalException extends RuntimeException {}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue