mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Rename methods and variables for code clarity
This commit is contained in:
parent
d2f1488934
commit
af8ab57e60
6 changed files with 21 additions and 19 deletions
|
@ -90,7 +90,7 @@ class KeyShareTests : InstrumentedTest {
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
val outgoingRequestBefore = aliceSession2.cryptoService().getOutgoingRoomKeyRequest()
|
val outgoingRequestsBefore = aliceSession2.cryptoService().getOutgoingRoomKeyRequests()
|
||||||
// Try to request
|
// Try to request
|
||||||
aliceSession2.cryptoService().requestRoomKeyForEvent(receivedEvent.root)
|
aliceSession2.cryptoService().requestRoomKeyForEvent(receivedEvent.root)
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ class KeyShareTests : InstrumentedTest {
|
||||||
var outGoingRequestId: String? = null
|
var outGoingRequestId: String? = null
|
||||||
|
|
||||||
mTestHelper.retryPeriodicallyWithLatch(waitLatch) {
|
mTestHelper.retryPeriodicallyWithLatch(waitLatch) {
|
||||||
aliceSession2.cryptoService().getOutgoingRoomKeyRequest()
|
aliceSession2.cryptoService().getOutgoingRoomKeyRequests()
|
||||||
.filter { req ->
|
.filter { req ->
|
||||||
// filter out request that was known before
|
// filter out request that was known before
|
||||||
!outgoingRequestBefore.any { req.requestId == it.requestId }
|
!outgoingRequestsBefore.any { req.requestId == it.requestId }
|
||||||
}
|
}
|
||||||
.let {
|
.let {
|
||||||
val outgoing = it.firstOrNull { it.sessionId == eventMegolmSessionId }
|
val outgoing = it.firstOrNull { it.sessionId == eventMegolmSessionId }
|
||||||
|
@ -115,10 +115,10 @@ class KeyShareTests : InstrumentedTest {
|
||||||
|
|
||||||
Log.v("TEST", "=======> Outgoing requet Id is $outGoingRequestId")
|
Log.v("TEST", "=======> Outgoing requet Id is $outGoingRequestId")
|
||||||
|
|
||||||
val outgoingRequestAfter = aliceSession2.cryptoService().getOutgoingRoomKeyRequest()
|
val outgoingRequestAfter = aliceSession2.cryptoService().getOutgoingRoomKeyRequests()
|
||||||
|
|
||||||
// We should have a new request
|
// We should have a new request
|
||||||
Assert.assertTrue(outgoingRequestAfter.size > outgoingRequestBefore.size)
|
Assert.assertTrue(outgoingRequestAfter.size > outgoingRequestsBefore.size)
|
||||||
Assert.assertNotNull(outgoingRequestAfter.first { it.sessionId == eventMegolmSessionId })
|
Assert.assertNotNull(outgoingRequestAfter.first { it.sessionId == eventMegolmSessionId })
|
||||||
|
|
||||||
// The first session should see an incoming request
|
// The first session should see an incoming request
|
||||||
|
@ -126,7 +126,7 @@ class KeyShareTests : InstrumentedTest {
|
||||||
mTestHelper.waitWithLatch { latch ->
|
mTestHelper.waitWithLatch { latch ->
|
||||||
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
// DEBUG LOGS
|
// DEBUG LOGS
|
||||||
aliceSession.cryptoService().getIncomingRoomKeyRequest().let {
|
aliceSession.cryptoService().getIncomingRoomKeyRequests().let {
|
||||||
Log.v("TEST", "Incoming request Session 1 (looking for $outGoingRequestId)")
|
Log.v("TEST", "Incoming request Session 1 (looking for $outGoingRequestId)")
|
||||||
Log.v("TEST", "=========================")
|
Log.v("TEST", "=========================")
|
||||||
it.forEach { keyRequest ->
|
it.forEach { keyRequest ->
|
||||||
|
@ -135,7 +135,7 @@ class KeyShareTests : InstrumentedTest {
|
||||||
Log.v("TEST", "=========================")
|
Log.v("TEST", "=========================")
|
||||||
}
|
}
|
||||||
|
|
||||||
val incoming = aliceSession.cryptoService().getIncomingRoomKeyRequest().firstOrNull { it.requestId == outGoingRequestId }
|
val incoming = aliceSession.cryptoService().getIncomingRoomKeyRequests().firstOrNull { it.requestId == outGoingRequestId }
|
||||||
incoming?.state == GossipingRequestState.REJECTED
|
incoming?.state == GossipingRequestState.REJECTED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ class KeyShareTests : InstrumentedTest {
|
||||||
|
|
||||||
mTestHelper.waitWithLatch { latch ->
|
mTestHelper.waitWithLatch { latch ->
|
||||||
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
aliceSession.cryptoService().getIncomingRoomKeyRequest().let {
|
aliceSession.cryptoService().getIncomingRoomKeyRequests().let {
|
||||||
Log.v("TEST", "Incoming request Session 1")
|
Log.v("TEST", "Incoming request Session 1")
|
||||||
Log.v("TEST", "=========================")
|
Log.v("TEST", "=========================")
|
||||||
it.forEach {
|
it.forEach {
|
||||||
|
@ -171,7 +171,7 @@ class KeyShareTests : InstrumentedTest {
|
||||||
Thread.sleep(6_000)
|
Thread.sleep(6_000)
|
||||||
mTestHelper.waitWithLatch { latch ->
|
mTestHelper.waitWithLatch { latch ->
|
||||||
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
aliceSession2.cryptoService().getOutgoingRoomKeyRequest().let {
|
aliceSession2.cryptoService().getOutgoingRoomKeyRequests().let {
|
||||||
it.any { it.requestBody?.sessionId == eventMegolmSessionId && it.state == OutgoingGossipingRequestState.CANCELLED }
|
it.any { it.requestBody?.sessionId == eventMegolmSessionId && it.state == OutgoingGossipingRequestState.CANCELLED }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,9 @@ interface CryptoService {
|
||||||
|
|
||||||
fun removeSessionListener(listener: NewSessionListener)
|
fun removeSessionListener(listener: NewSessionListener)
|
||||||
|
|
||||||
fun getOutgoingRoomKeyRequest(): List<OutgoingRoomKeyRequest>
|
fun getOutgoingRoomKeyRequests(): List<OutgoingRoomKeyRequest>
|
||||||
fun getIncomingRoomKeyRequest(): List<IncomingRoomKeyRequest>
|
|
||||||
|
fun getIncomingRoomKeyRequests(): List<IncomingRoomKeyRequest>
|
||||||
|
|
||||||
fun getGossipingEventsTrail(): List<Event>
|
fun getGossipingEventsTrail(): List<Event>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1262,11 +1262,11 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
return "DefaultCryptoService of $userId ($deviceId)"
|
return "DefaultCryptoService of $userId ($deviceId)"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getOutgoingRoomKeyRequest(): List<OutgoingRoomKeyRequest> {
|
override fun getOutgoingRoomKeyRequests(): List<OutgoingRoomKeyRequest> {
|
||||||
return cryptoStore.getOutgoingRoomKeyRequests()
|
return cryptoStore.getOutgoingRoomKeyRequests()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIncomingRoomKeyRequest(): List<IncomingRoomKeyRequest> {
|
override fun getIncomingRoomKeyRequests(): List<IncomingRoomKeyRequest> {
|
||||||
return cryptoStore.getIncomingRoomKeyRequests()
|
return cryptoStore.getIncomingRoomKeyRequests()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class GossipingEventsEpoxyController @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildOutgoing(data: KeyRequestListViewState?) {
|
private fun buildOutgoing(data: KeyRequestListViewState?) {
|
||||||
data?.outgoingRoomKeyRequest?.let { async ->
|
data?.outgoingRoomKeyRequests?.let { async ->
|
||||||
when (async) {
|
when (async) {
|
||||||
is Uninitialized,
|
is Uninitialized,
|
||||||
is Loading -> {
|
is Loading -> {
|
||||||
|
|
|
@ -107,7 +107,7 @@ class KeyRequestEpoxyController @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildOutgoing(data: KeyRequestListViewState?) {
|
private fun buildOutgoing(data: KeyRequestListViewState?) {
|
||||||
data?.outgoingRoomKeyRequest?.let { async ->
|
data?.outgoingRoomKeyRequests?.let { async ->
|
||||||
when (async) {
|
when (async) {
|
||||||
is Uninitialized,
|
is Uninitialized,
|
||||||
is Loading -> {
|
is Loading -> {
|
||||||
|
|
|
@ -36,7 +36,7 @@ import kotlinx.coroutines.launch
|
||||||
|
|
||||||
data class KeyRequestListViewState(
|
data class KeyRequestListViewState(
|
||||||
val incomingRequests: Async<List<IncomingRoomKeyRequest>> = Uninitialized,
|
val incomingRequests: Async<List<IncomingRoomKeyRequest>> = Uninitialized,
|
||||||
val outgoingRoomKeyRequest: Async<List<OutgoingRoomKeyRequest>> = Uninitialized
|
val outgoingRoomKeyRequests: Async<List<OutgoingRoomKeyRequest>> = Uninitialized
|
||||||
) : MvRxState
|
) : MvRxState
|
||||||
|
|
||||||
class KeyRequestListViewModel @AssistedInject constructor(@Assisted initialState: KeyRequestListViewState,
|
class KeyRequestListViewModel @AssistedInject constructor(@Assisted initialState: KeyRequestListViewState,
|
||||||
|
@ -49,14 +49,14 @@ class KeyRequestListViewModel @AssistedInject constructor(@Assisted initialState
|
||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
session.cryptoService().getOutgoingRoomKeyRequest().let {
|
session.cryptoService().getOutgoingRoomKeyRequests().let {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
outgoingRoomKeyRequest = Success(it)
|
outgoingRoomKeyRequests = Success(it)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.cryptoService().getIncomingRoomKeyRequest().let {
|
session.cryptoService().getIncomingRoomKeyRequests().let {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
incomingRequests = Success(it)
|
incomingRequests = Success(it)
|
||||||
|
|
Loading…
Reference in a new issue