mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Code review
This commit is contained in:
parent
9c9695546c
commit
48fffc3dcf
4 changed files with 10 additions and 15 deletions
|
@ -113,14 +113,6 @@ interface CryptoService {
|
|||
|
||||
fun isRoomEncrypted(roomId: String): Boolean
|
||||
|
||||
/**
|
||||
* This is a bit different than isRoomEncrypted
|
||||
* A room is encrypted when there is a m.room.encryption state event in the room (malformed/invalid or not)
|
||||
* But the crypto layer has additional guaranty to ensure that encryption would never been reverted
|
||||
* It's defensive coding out of precaution (if ever state is reset)
|
||||
*/
|
||||
fun shouldEncryptInRoom(roomId: String?): Boolean
|
||||
|
||||
fun encryptEventContent(eventContent: Content,
|
||||
eventType: String,
|
||||
roomId: String,
|
||||
|
|
|
@ -634,10 +634,6 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
return cryptoSessionInfoProvider.isRoomEncrypted(roomId)
|
||||
}
|
||||
|
||||
override fun shouldEncryptInRoom(roomId: String?): Boolean {
|
||||
return roomId?.let { cryptoStore.roomWasOnceEncrypted(it) } ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stored device keys for a user.
|
||||
*/
|
||||
|
|
|
@ -240,6 +240,12 @@ internal interface IMXCryptoStore {
|
|||
*/
|
||||
fun getRoomAlgorithm(roomId: String): String?
|
||||
|
||||
/**
|
||||
* This is a bit different than isRoomEncrypted
|
||||
* A room is encrypted when there is a m.room.encryption state event in the room (malformed/invalid or not)
|
||||
* But the crypto layer has additional guaranty to ensure that encryption would never been reverted
|
||||
* It's defensive coding out of precaution (if ever state is reset)
|
||||
*/
|
||||
fun roomWasOnceEncrypted(roomId: String): Boolean
|
||||
|
||||
fun shouldEncryptForInvitedMembers(roomId: String): Boolean
|
||||
|
|
|
@ -26,9 +26,9 @@ import org.matrix.android.sdk.api.failure.Failure
|
|||
import org.matrix.android.sdk.api.failure.getRetryDelay
|
||||
import org.matrix.android.sdk.api.failure.isLimitExceededError
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.util.Cancelable
|
||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||
import org.matrix.android.sdk.internal.session.SessionScope
|
||||
import org.matrix.android.sdk.internal.task.CoroutineSequencer
|
||||
import org.matrix.android.sdk.internal.task.SemaphoreCoroutineSequencer
|
||||
|
@ -54,7 +54,7 @@ private const val MAX_RETRY_COUNT = 3
|
|||
*/
|
||||
@SessionScope
|
||||
internal class EventSenderProcessorCoroutine @Inject constructor(
|
||||
private val cryptoService: CryptoService,
|
||||
private val cryptoStore: IMXCryptoStore,
|
||||
private val sessionParams: SessionParams,
|
||||
private val queuedTaskFactory: QueuedTaskFactory,
|
||||
private val taskExecutor: TaskExecutor,
|
||||
|
@ -92,7 +92,8 @@ internal class EventSenderProcessorCoroutine @Inject constructor(
|
|||
}
|
||||
|
||||
override fun postEvent(event: Event): Cancelable {
|
||||
return postEvent(event, cryptoService.shouldEncryptInRoom(event.roomId))
|
||||
val shouldEncrypt = event.roomId?.let { cryptoStore.roomWasOnceEncrypted(it) } ?: false
|
||||
return postEvent(event, shouldEncrypt)
|
||||
}
|
||||
|
||||
override fun postEvent(event: Event, encrypt: Boolean): Cancelable {
|
||||
|
|
Loading…
Reference in a new issue