Add incoming key forward trail
This commit is contained in:
parent
b1db6ca180
commit
ae6df469e2
@ -234,6 +234,15 @@ internal class MXMegolmDecryption(
|
|||||||
fromDevice = fromDevice,
|
fromDevice = fromDevice,
|
||||||
event = event)
|
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
|
// 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)
|
outgoingKeyRequestManager.postCancelRequestForSessionIfNeeded(roomKeyContent.sessionId, roomKeyContent.roomId, senderKey, index)
|
||||||
}
|
}
|
||||||
|
@ -417,6 +417,16 @@ internal interface IMXCryptoStore {
|
|||||||
chainIndex: Long?
|
chainIndex: Long?
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun saveIncomingForwardKeyAuditTrail(
|
||||||
|
roomId: String,
|
||||||
|
sessionId: String,
|
||||||
|
senderKey: String,
|
||||||
|
algorithm: String,
|
||||||
|
userId: String,
|
||||||
|
deviceId: String,
|
||||||
|
chainIndex: Long?
|
||||||
|
)
|
||||||
|
|
||||||
fun addNewSessionListener(listener: NewSessionListener)
|
fun addNewSessionListener(listener: NewSessionListener)
|
||||||
|
|
||||||
fun removeSessionListener(listener: NewSessionListener)
|
fun removeSessionListener(listener: NewSessionListener)
|
||||||
|
@ -1269,30 +1269,51 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveForwardKeyAuditTrail(roomId: String,
|
override fun saveForwardKeyAuditTrail(roomId: String,
|
||||||
sessionId: String,
|
sessionId: String,
|
||||||
senderKey: String,
|
senderKey: String,
|
||||||
algorithm: String,
|
algorithm: String,
|
||||||
userId: String,
|
userId: String,
|
||||||
deviceId: String,
|
deviceId: String,
|
||||||
chainIndex: Long?) {
|
chainIndex: Long?) {
|
||||||
monarchy.writeAsync { realm ->
|
saveForwardKeyTrail(roomId, sessionId, senderKey, algorithm, userId, deviceId, chainIndex, false)
|
||||||
val now = System.currentTimeMillis()
|
}
|
||||||
realm.createObject<AuditTrailEntity>().apply {
|
|
||||||
this.ageLocalTs = now
|
override fun saveIncomingForwardKeyAuditTrail(roomId: String,
|
||||||
this.type = TrailType.OutgoingKeyForward.name
|
sessionId: String,
|
||||||
val info = ForwardInfo(
|
senderKey: String,
|
||||||
roomId = roomId,
|
algorithm: String,
|
||||||
sessionId = sessionId,
|
userId: String,
|
||||||
senderKey = senderKey,
|
deviceId: String,
|
||||||
alg = algorithm,
|
chainIndex: Long?) {
|
||||||
userId = userId,
|
saveForwardKeyTrail(roomId, sessionId, senderKey, algorithm, userId, deviceId, chainIndex, true)
|
||||||
deviceId = deviceId,
|
}
|
||||||
chainIndex = chainIndex
|
|
||||||
)
|
private fun saveForwardKeyTrail(roomId: String,
|
||||||
MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).toJson(info)?.let {
|
sessionId: String,
|
||||||
this.contentJson = it
|
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} ")
|
append("code: ${it.code} ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TrailType.IncomingKeyForward -> {
|
||||||
|
append("from:${info.userId}|${info.deviceId} - ")
|
||||||
|
(trail.info as? ForwardInfo)?.let {
|
||||||
|
append("chainIndex: ${it.chainIndex} ")
|
||||||
|
}
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
append("??")
|
append("??")
|
||||||
}
|
}
|
||||||
|
@ -89,10 +89,13 @@ class GossipingTrailPagedEpoxyController @Inject constructor(
|
|||||||
// no additional info
|
// no additional info
|
||||||
}
|
}
|
||||||
TrailType.IncomingKeyForward -> {
|
TrailType.IncomingKeyForward -> {
|
||||||
|
val fInfo = event.info as ForwardInfo
|
||||||
|
span("\nchainIndex: ") {
|
||||||
|
textStyle = "bold"
|
||||||
|
}
|
||||||
|
+"${fInfo.chainIndex}"
|
||||||
}
|
}
|
||||||
TrailType.Unknown -> {
|
TrailType.Unknown -> {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class IncomingKeyRequestPagedController @Inject constructor(
|
|||||||
textStyle = "bold"
|
textStyle = "bold"
|
||||||
}
|
}
|
||||||
span("${roomKeyRequest.userId}")
|
span("${roomKeyRequest.userId}")
|
||||||
|
+"\n"
|
||||||
+host.vectorDateFormatter.format(roomKeyRequest.localCreationTimestamp, DateFormatKind.DEFAULT_DATE_AND_TIME)
|
+host.vectorDateFormatter.format(roomKeyRequest.localCreationTimestamp, DateFormatKind.DEFAULT_DATE_AND_TIME)
|
||||||
span("\nsessionId:") {
|
span("\nsessionId:") {
|
||||||
textStyle = "bold"
|
textStyle = "bold"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user