mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
View source in audit + clean
This commit is contained in:
parent
5e2f888eaf
commit
75549c41e0
@ -142,12 +142,12 @@ data class Event(
|
||||
}
|
||||
|
||||
fun toContentStringWithIndent(): String {
|
||||
val contentMap = toContent().toMutableMap()
|
||||
val contentMap = toContent()
|
||||
return JSONObject(contentMap).toString(4)
|
||||
}
|
||||
|
||||
fun toClearContentStringWithIndent(): String? {
|
||||
val contentMap = this.mxDecryptionResult?.payload?.toMutableMap()
|
||||
val contentMap = this.mxDecryptionResult?.payload
|
||||
val adapter = MoshiProvider.providesMoshi().adapter(Map::class.java)
|
||||
return contentMap?.let { JSONObject(adapter.toJson(it)).toString(4) }
|
||||
}
|
||||
|
@ -776,14 +776,12 @@ internal class DefaultCryptoService @Inject constructor(
|
||||
}
|
||||
|
||||
when (existingRequest.secretName) {
|
||||
// "m.key.self_signing",
|
||||
SELF_SIGNING_KEY_SSSS_NAME -> {
|
||||
if (device.trustLevel?.isLocallyVerified() == true) {
|
||||
crossSigningService.onSecretSSKGossip(secretContent.secretValue)
|
||||
return
|
||||
}
|
||||
}
|
||||
// "m.key.user_signing",
|
||||
USER_SIGNING_KEY_SSSS_NAME -> {
|
||||
if (device.trustLevel?.isLocallyVerified() == true) {
|
||||
cryptoStore.storePrivateKeysInfo(null, null, secretContent.secretValue)
|
||||
|
@ -22,7 +22,7 @@ import com.squareup.moshi.JsonClass
|
||||
* Class representing a room key request content
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class SecretShareRequest(
|
||||
data class SecretShareRequest(
|
||||
@Json(name = "action")
|
||||
override val action: String? = GossipingToDeviceObject.ACTION_SHARE_REQUEST,
|
||||
|
||||
|
@ -74,11 +74,10 @@ internal abstract class DefaultVerificationTransaction(
|
||||
// Mark my keys as trusted locally
|
||||
crossSigningService.markMyMasterKeyAsTrusted()
|
||||
}
|
||||
|
||||
if (!crossSigningService.canCrossSign()) {
|
||||
outgoingGossipingRequestManager.sendSecretShareRequest(SELF_SIGNING_KEY_SSSS_NAME, mapOf(userId to listOf(otherDeviceId ?: "*")))
|
||||
outgoingGossipingRequestManager.sendSecretShareRequest(USER_SIGNING_KEY_SSSS_NAME, mapOf(userId to listOf(otherDeviceId ?: "*")))
|
||||
// outgoingGossipingRequestManager.sendSecretShareRequest("m.key.self_signing", mapOf(userId to listOf(otherDeviceId ?: "*")))
|
||||
// outgoingGossipingRequestManager.sendSecretShareRequest("m.key.user_signing", mapOf(userId to listOf(otherDeviceId ?: "*")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,11 @@ import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.api.session.events.model.toModel
|
||||
import im.vector.matrix.android.internal.crypto.model.event.OlmEventContent
|
||||
import im.vector.matrix.android.internal.crypto.model.event.SecretSendEventContent
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.ForwardedRoomKeyContent
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.GossipingToDeviceObject
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShareRequest
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.SecretShareRequest
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.date.VectorDateFormatter
|
||||
import im.vector.riotx.core.epoxy.loadingItem
|
||||
@ -35,6 +37,7 @@ import im.vector.riotx.core.extensions.exhaustive
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import im.vector.riotx.core.resources.DateProvider
|
||||
import im.vector.riotx.core.resources.StringProvider
|
||||
import im.vector.riotx.core.ui.list.GenericItem
|
||||
import im.vector.riotx.core.ui.list.genericFooterItem
|
||||
import im.vector.riotx.core.ui.list.genericItem
|
||||
import im.vector.riotx.core.ui.list.genericItemHeader
|
||||
@ -81,6 +84,7 @@ class GossipingEventsEpoxyController @Inject constructor(
|
||||
eventList.forEachIndexed { _, event ->
|
||||
genericItem {
|
||||
id(event.hashCode())
|
||||
itemClickAction(GenericItem.Action("view").apply { perform = Runnable { interactionListener?.didTap(event) } })
|
||||
title(
|
||||
if (event.isEncrypted()) {
|
||||
"${event.getClearType()} [encrypted]"
|
||||
@ -133,6 +137,37 @@ class GossipingEventsEpoxyController @Inject constructor(
|
||||
textStyle = "bold"
|
||||
}
|
||||
+" ${encryptedContent?.senderKey}"
|
||||
} else if (event.getClearType() == EventType.SEND_SECRET) {
|
||||
val content = event.getClearContent().toModel<SecretSendEventContent>()
|
||||
|
||||
span("\nrequestId:") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+" ${content?.requestId}"
|
||||
span("\nFrom Device:") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+" ${event.mxDecryptionResult?.payload?.get("sender_device")}"
|
||||
} else if (event.getClearType() == EventType.REQUEST_SECRET) {
|
||||
val content = event.getClearContent().toModel<SecretShareRequest>()
|
||||
span("\nreqId:") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+" ${content?.requestId}"
|
||||
span("\naction:") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+" ${content?.action}"
|
||||
if (content?.action == GossipingToDeviceObject.ACTION_SHARE_REQUEST) {
|
||||
span("\nsecretName:") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+" ${content.secretName}"
|
||||
}
|
||||
span("\nrequestedBy: ") {
|
||||
textStyle = "bold"
|
||||
}
|
||||
+"${content?.requestingDeviceId}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,17 +21,22 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.extensions.cleanup
|
||||
import im.vector.riotx.core.extensions.configureWith
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import im.vector.riotx.core.utils.jsonViewerStyler
|
||||
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
|
||||
import org.billcarsonfr.jsonviewer.JSonViewerDialog
|
||||
import javax.inject.Inject
|
||||
|
||||
class GossipingEventsPaperTrailFragment @Inject constructor(
|
||||
val viewModelFactory: GossipingEventsPaperTrailViewModel.Factory,
|
||||
private val epoxyController: GossipingEventsEpoxyController
|
||||
) : VectorBaseFragment() {
|
||||
private val epoxyController: GossipingEventsEpoxyController,
|
||||
private val colorProvider: ColorProvider
|
||||
) : VectorBaseFragment(), GossipingEventsEpoxyController.InteractionListener {
|
||||
|
||||
override fun getLayoutResId() = R.layout.fragment_generic_recycler
|
||||
|
||||
@ -46,13 +51,13 @@ class GossipingEventsPaperTrailFragment @Inject constructor(
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
recyclerView.configureWith(epoxyController, showDivider = true)
|
||||
// epoxyController.interactionListener = this
|
||||
epoxyController.interactionListener = this
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
recyclerView.cleanup()
|
||||
// epoxyController.interactionListener = null
|
||||
epoxyController.interactionListener = null
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@ -63,4 +68,18 @@ class GossipingEventsPaperTrailFragment @Inject constructor(
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
override fun didTap(event: Event) {
|
||||
if (event.isEncrypted()) {
|
||||
event.toClearContentStringWithIndent()
|
||||
} else {
|
||||
event.toContentStringWithIndent()
|
||||
}?.let {
|
||||
JSonViewerDialog.newInstance(
|
||||
it,
|
||||
-1,
|
||||
jsonViewerStyler(colorProvider)
|
||||
).show(childFragmentManager, "JSON_VIEWER")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user