mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Add incoming key forward trail
This commit is contained in:
parent
b1db6ca180
commit
ae6df469e2
6 changed files with 76 additions and 26 deletions
|
@ -234,6 +234,15 @@ internal class MXMegolmDecryption(
|
|||
fromDevice = fromDevice,
|
||||
event = event)
|
||||
|
||||
cryptoStore.saveIncomingForwardKeyAuditTrail(
|
||||
roomId = roomKeyContent.roomId,
|
||||
sessionId = roomKeyContent.sessionId,
|
||||
senderKey = senderKey,
|
||||
algorithm = roomKeyContent.algorithm ?: "",
|
||||
userId = event.senderId ?: "",
|
||||
deviceId = fromDevice ?: "",
|
||||
chainIndex = index.toLong())
|
||||
|
||||
// The index is used to decide if we cancel sent request or if we wait for a better key
|
||||
outgoingKeyRequestManager.postCancelRequestForSessionIfNeeded(roomKeyContent.sessionId, roomKeyContent.roomId, senderKey, index)
|
||||
}
|
||||
|
|
|
@ -417,6 +417,16 @@ internal interface IMXCryptoStore {
|
|||
chainIndex: Long?
|
||||
)
|
||||
|
||||
fun saveIncomingForwardKeyAuditTrail(
|
||||
roomId: String,
|
||||
sessionId: String,
|
||||
senderKey: String,
|
||||
algorithm: String,
|
||||
userId: String,
|
||||
deviceId: String,
|
||||
chainIndex: Long?
|
||||
)
|
||||
|
||||
fun addNewSessionListener(listener: NewSessionListener)
|
||||
|
||||
fun removeSessionListener(listener: NewSessionListener)
|
||||
|
|
|
@ -1269,30 +1269,51 @@ internal class RealmCryptoStore @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun saveForwardKeyAuditTrail(roomId: String,
|
||||
sessionId: String,
|
||||
senderKey: String,
|
||||
algorithm: String,
|
||||
userId: String,
|
||||
deviceId: String,
|
||||
chainIndex: Long?) {
|
||||
monarchy.writeAsync { realm ->
|
||||
val now = System.currentTimeMillis()
|
||||
realm.createObject<AuditTrailEntity>().apply {
|
||||
this.ageLocalTs = now
|
||||
this.type = TrailType.OutgoingKeyForward.name
|
||||
val info = ForwardInfo(
|
||||
roomId = roomId,
|
||||
sessionId = sessionId,
|
||||
senderKey = senderKey,
|
||||
alg = algorithm,
|
||||
userId = userId,
|
||||
deviceId = deviceId,
|
||||
chainIndex = chainIndex
|
||||
)
|
||||
MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).toJson(info)?.let {
|
||||
this.contentJson = it
|
||||
}
|
||||
override fun saveForwardKeyAuditTrail(roomId: String,
|
||||
sessionId: String,
|
||||
senderKey: String,
|
||||
algorithm: String,
|
||||
userId: String,
|
||||
deviceId: String,
|
||||
chainIndex: Long?) {
|
||||
saveForwardKeyTrail(roomId, sessionId, senderKey, algorithm, userId, deviceId, chainIndex, false)
|
||||
}
|
||||
|
||||
override fun saveIncomingForwardKeyAuditTrail(roomId: String,
|
||||
sessionId: String,
|
||||
senderKey: String,
|
||||
algorithm: String,
|
||||
userId: String,
|
||||
deviceId: String,
|
||||
chainIndex: Long?) {
|
||||
saveForwardKeyTrail(roomId, sessionId, senderKey, algorithm, userId, deviceId, chainIndex, true)
|
||||
}
|
||||
|
||||
private fun saveForwardKeyTrail(roomId: String,
|
||||
sessionId: String,
|
||||
senderKey: String,
|
||||
algorithm: String,
|
||||
userId: String,
|
||||
deviceId: String,
|
||||
chainIndex: Long?,
|
||||
incoming: Boolean
|
||||
) {
|
||||
monarchy.writeAsync { realm ->
|
||||
val now = System.currentTimeMillis()
|
||||
realm.createObject<AuditTrailEntity>().apply {
|
||||
this.ageLocalTs = now
|
||||
this.type = if (incoming) TrailType.IncomingKeyForward.name else TrailType.OutgoingKeyForward.name
|
||||
val info = ForwardInfo(
|
||||
roomId = roomId,
|
||||
sessionId = sessionId,
|
||||
senderKey = senderKey,
|
||||
alg = algorithm,
|
||||
userId = userId,
|
||||
deviceId = deviceId,
|
||||
chainIndex = chainIndex
|
||||
)
|
||||
MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).toJson(info)?.let {
|
||||
this.contentJson = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,12 @@ class GossipingEventsSerializer {
|
|||
append("code: ${it.code} ")
|
||||
}
|
||||
}
|
||||
TrailType.IncomingKeyForward -> {
|
||||
append("from:${info.userId}|${info.deviceId} - ")
|
||||
(trail.info as? ForwardInfo)?.let {
|
||||
append("chainIndex: ${it.chainIndex} ")
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
append("??")
|
||||
}
|
||||
|
|
|
@ -89,10 +89,13 @@ class GossipingTrailPagedEpoxyController @Inject constructor(
|
|||
// no additional info
|
||||
}
|
||||
TrailType.IncomingKeyForward -> {
|
||||
|
||||
val fInfo = event.info as ForwardInfo
|
||||
span("\nchainIndex: ") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+"${fInfo.chainIndex}"
|
||||
}
|
||||
TrailType.Unknown -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ class IncomingKeyRequestPagedController @Inject constructor(
|
|||
textStyle = "bold"
|
||||
}
|
||||
span("${roomKeyRequest.userId}")
|
||||
+"\n"
|
||||
+host.vectorDateFormatter.format(roomKeyRequest.localCreationTimestamp, DateFormatKind.DEFAULT_DATE_AND_TIME)
|
||||
span("\nsessionId:") {
|
||||
textStyle = "bold"
|
||||
|
|
Loading…
Reference in a new issue