Update default conflict method to be 'ignore'.

This commit is contained in:
Greyson Parrelli 2023-05-12 09:26:44 -04:00
parent 6615bc4a2a
commit 2eff9e0230
4 changed files with 18 additions and 10 deletions

View file

@ -292,7 +292,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
TIMESTAMP to timestamp,
DELETION_TIMESTAMP to System.currentTimeMillis()
)
.run()
.run(SQLiteDatabase.CONFLICT_ABORT)
ApplicationDependencies.getDeletedCallEventManager().scheduleIfNecessary()
}
@ -356,7 +356,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
TIMESTAMP to timestamp,
RINGER to ringer
)
.run()
.run(SQLiteDatabase.CONFLICT_ABORT)
}
ApplicationDependencies.getDatabaseObserver().notifyCallUpdateObservers()
@ -462,7 +462,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
TIMESTAMP to timestamp,
RINGER to null
)
.run()
.run(SQLiteDatabase.CONFLICT_ABORT)
Log.d(TAG, "Inserted new call event from group call update message. Call Id: $callId")
} else {
@ -670,7 +670,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
TIMESTAMP to timestamp,
RINGER to ringerRecipient.toLong()
)
.run()
.run(SQLiteDatabase.CONFLICT_ABORT)
}
Log.d(TAG, "Inserted a new group ring event for $callId with event $event")

View file

@ -2725,7 +2725,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
READ to if (Util.isDefaultSmsProvider(context)) 0 else 1,
SMS_SUBSCRIPTION_ID to subscriptionId
)
.run()
.run(SQLiteDatabase.CONFLICT_IGNORE)
return Pair(messageId, threadId)
}
@ -3041,6 +3041,10 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
unarchive = false
)
if (messageId < 0) {
throw MmsException("Failed to insert message! Likely a duplicate.")
}
if (message.threadRecipient.isGroup) {
val members: MutableSet<RecipientId> = mutableSetOf()

View file

@ -80,11 +80,15 @@ public class MmsReceiveJob extends BaseJob {
MessageTable database = SignalDatabase.messages();
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox((NotificationInd)pdu, subscriptionId);
Log.i(TAG, "Inserted received MMS notification...");
if (messageAndThreadId.first() > 0) {
Log.i(TAG, "Inserted received MMS notification...");
ApplicationDependencies.getJobManager().add(new MmsDownloadJob(messageAndThreadId.first(),
messageAndThreadId.second(),
true));
ApplicationDependencies.getJobManager().add(new MmsDownloadJob(messageAndThreadId.first(),
messageAndThreadId.second(),
true));
} else {
Log.w(TAG, "Did not insert MMS because it was a duplicate!");
}
} else {
Log.w(TAG, "Unable to process MMS.");
}

View file

@ -369,7 +369,7 @@ class InsertBuilderPart2(
private val tableName: String,
private val values: ContentValues
) {
fun run(conflictStrategy: Int = SQLiteDatabase.CONFLICT_NONE): Long {
fun run(conflictStrategy: Int = SQLiteDatabase.CONFLICT_IGNORE): Long {
return db.insert(tableName, conflictStrategy, values)
}
}