mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Fix individual and adhoc call backup import/export.
This commit is contained in:
@@ -6,8 +6,7 @@
|
||||
package org.thoughtcrime.securesms.backup.v2.database
|
||||
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.insertInto
|
||||
import org.signal.core.util.requireLong
|
||||
import org.signal.core.util.select
|
||||
import org.thoughtcrime.securesms.backup.v2.ImportState
|
||||
@@ -21,7 +20,7 @@ fun CallTable.getAdhocCallsForBackup(): CallLogIterator {
|
||||
readableDatabase
|
||||
.select()
|
||||
.from(CallTable.TABLE_NAME)
|
||||
.where("${CallTable.TYPE}=?", CallTable.Type.AD_HOC_CALL)
|
||||
.where("${CallTable.TYPE} = ?", CallTable.Type.serialize(CallTable.Type.AD_HOC_CALL))
|
||||
.run()
|
||||
)
|
||||
}
|
||||
@@ -32,16 +31,18 @@ fun CallTable.restoreCallLogFromBackup(call: AdHocCall, importState: ImportState
|
||||
AdHocCall.State.UNKNOWN_STATE -> CallTable.Event.GENERIC_GROUP_CALL
|
||||
}
|
||||
|
||||
val values = contentValuesOf(
|
||||
CallTable.CALL_ID to call.callId,
|
||||
CallTable.PEER to importState.remoteToLocalRecipientId[call.recipientId]!!.serialize(),
|
||||
CallTable.TYPE to CallTable.Type.serialize(CallTable.Type.AD_HOC_CALL),
|
||||
CallTable.DIRECTION to CallTable.Direction.serialize(CallTable.Direction.OUTGOING),
|
||||
CallTable.EVENT to CallTable.Event.serialize(event),
|
||||
CallTable.TIMESTAMP to call.callTimestamp
|
||||
)
|
||||
|
||||
writableDatabase.insert(CallTable.TABLE_NAME, SQLiteDatabase.CONFLICT_IGNORE, values)
|
||||
val result = writableDatabase
|
||||
.insertInto(CallTable.TABLE_NAME)
|
||||
.values(
|
||||
CallTable.CALL_ID to call.callId,
|
||||
CallTable.PEER to importState.remoteToLocalRecipientId[call.recipientId]!!.serialize(),
|
||||
CallTable.TYPE to CallTable.Type.serialize(CallTable.Type.AD_HOC_CALL),
|
||||
CallTable.DIRECTION to CallTable.Direction.serialize(CallTable.Direction.OUTGOING),
|
||||
CallTable.EVENT to CallTable.Event.serialize(event),
|
||||
CallTable.TIMESTAMP to call.callTimestamp
|
||||
)
|
||||
.run()
|
||||
return Unit
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -460,7 +460,8 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
)
|
||||
}
|
||||
|
||||
CallTable.Type.AD_HOC_CALL -> {
|
||||
CallTable.Type.AUDIO_CALL,
|
||||
CallTable.Type.VIDEO_CALL -> {
|
||||
ChatUpdateMessage(
|
||||
individualCall = IndividualCall(
|
||||
callId = this.callId,
|
||||
@@ -473,12 +474,13 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
CallTable.Event.NOT_ACCEPTED -> IndividualCall.State.NOT_ACCEPTED
|
||||
else -> IndividualCall.State.UNKNOWN_STATE
|
||||
},
|
||||
startedCallTimestamp = this.timestamp
|
||||
startedCallTimestamp = this.timestamp,
|
||||
read = messageRecord.read
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> null
|
||||
CallTable.Type.AD_HOC_CALL -> throw IllegalArgumentException("AdHoc calls are not update messages!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -696,6 +696,7 @@ class ChatItemImportInserter(
|
||||
}
|
||||
}
|
||||
}
|
||||
this.put(MessageTable.READ, updateMessage.individualCall.read.toInt())
|
||||
}
|
||||
updateMessage.groupCall != null -> {
|
||||
val startedCallRecipientId = if (updateMessage.groupCall.startedCallRecipientId != null) {
|
||||
|
||||
Reference in New Issue
Block a user