Code review
This commit is contained in:
parent
93070f3524
commit
0d0af6906e
@ -29,6 +29,7 @@ Improvements 🙌:
|
||||
- Cross-Signing | Hide Use recovery key when 4S is not setup (#1007)
|
||||
- Cross-Signing | Trust account xSigning keys by entering Recovery Key (select file or copy) #1199
|
||||
- Manage Session Settings / Cross Signing update (#1295)
|
||||
- Cross-Signing | Review sessions toast update old vs new (#1293, #1306)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Fix summary notification staying after "mark as read"
|
||||
|
@ -61,9 +61,9 @@ class RxSession(private val session: Session) {
|
||||
}
|
||||
|
||||
fun liveMyDeviceInfo(): Observable<List<DeviceInfo>> {
|
||||
return session.cryptoService().getLiveMyDeviceInfo().asObservable()
|
||||
return session.cryptoService().getLiveMyDevicesInfo().asObservable()
|
||||
.startWithCallable {
|
||||
session.cryptoService().getMyDeviceInfo()
|
||||
session.cryptoService().getMyDevicesInfo()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,8 @@ interface CryptoService {
|
||||
fun removeRoomKeysRequestListener(listener: GossipingRequestListener)
|
||||
|
||||
fun fetchDevicesList(callback: MatrixCallback<DevicesListResponse>)
|
||||
fun getMyDeviceInfo() : List<DeviceInfo>
|
||||
fun getLiveMyDeviceInfo() : LiveData<List<DeviceInfo>>
|
||||
fun getMyDevicesInfo() : List<DeviceInfo>
|
||||
fun getLiveMyDevicesInfo() : LiveData<List<DeviceInfo>>
|
||||
|
||||
fun getDeviceInfo(deviceId: String, callback: MatrixCallback<DeviceInfo>)
|
||||
|
||||
|
@ -262,7 +262,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||
|
||||
override fun onSuccess(data: DevicesListResponse) {
|
||||
// Save in local DB
|
||||
cryptoStore.saveMyDeviceInfos(data.devices ?: emptyList())
|
||||
cryptoStore.saveMyDevicesInfo(data.devices ?: emptyList())
|
||||
callback.onSuccess(data)
|
||||
}
|
||||
}
|
||||
@ -270,12 +270,12 @@ internal class DefaultCryptoService @Inject constructor(
|
||||
.executeBy(taskExecutor)
|
||||
}
|
||||
|
||||
override fun getLiveMyDeviceInfo(): LiveData<List<DeviceInfo>> {
|
||||
return cryptoStore.getLiveMyDeviceInfo()
|
||||
override fun getLiveMyDevicesInfo(): LiveData<List<DeviceInfo>> {
|
||||
return cryptoStore.getLiveMyDevicesInfo()
|
||||
}
|
||||
|
||||
override fun getMyDeviceInfo(): List<DeviceInfo> {
|
||||
return cryptoStore.getMyDeviceInfo()
|
||||
override fun getMyDevicesInfo(): List<DeviceInfo> {
|
||||
return cryptoStore.getMyDevicesInfo()
|
||||
}
|
||||
|
||||
override fun getDeviceInfo(deviceId: String, callback: MatrixCallback<DeviceInfo>) {
|
||||
|
@ -30,7 +30,7 @@ data class CryptoDeviceInfo(
|
||||
val unsigned: JsonDict? = null,
|
||||
var trustLevel: DeviceTrustLevel? = null,
|
||||
var isBlocked: Boolean = false,
|
||||
val firsTimeSeenLocalTs: Long? = null
|
||||
val firstTimeSeenLocalTs: Long? = null
|
||||
) : CryptoInfo {
|
||||
|
||||
val isVerified: Boolean
|
||||
|
@ -219,9 +219,9 @@ internal interface IMXCryptoStore {
|
||||
// TODO temp
|
||||
fun getLiveDeviceList(): LiveData<List<CryptoDeviceInfo>>
|
||||
|
||||
fun getMyDeviceInfo() : List<DeviceInfo>
|
||||
fun getLiveMyDeviceInfo() : LiveData<List<DeviceInfo>>
|
||||
fun saveMyDeviceInfos(info: List<DeviceInfo>)
|
||||
fun getMyDevicesInfo() : List<DeviceInfo>
|
||||
fun getLiveMyDevicesInfo() : LiveData<List<DeviceInfo>>
|
||||
fun saveMyDevicesInfo(info: List<DeviceInfo>)
|
||||
/**
|
||||
* Store the crypto algorithm for a room.
|
||||
*
|
||||
|
@ -509,7 +509,7 @@ internal class RealmCryptoStore @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMyDeviceInfo(): List<DeviceInfo> {
|
||||
override fun getMyDevicesInfo(): List<DeviceInfo> {
|
||||
return monarchy.fetchAllCopiedSync {
|
||||
it.where<MyDeviceLastSeenInfoEntity>()
|
||||
}.map {
|
||||
@ -522,7 +522,7 @@ internal class RealmCryptoStore @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLiveMyDeviceInfo(): LiveData<List<DeviceInfo>> {
|
||||
override fun getLiveMyDevicesInfo(): LiveData<List<DeviceInfo>> {
|
||||
return monarchy.findAllMappedWithChanges(
|
||||
{ realm: Realm ->
|
||||
realm.where<MyDeviceLastSeenInfoEntity>()
|
||||
@ -538,7 +538,7 @@ internal class RealmCryptoStore @Inject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun saveMyDeviceInfos(info: List<DeviceInfo>) {
|
||||
override fun saveMyDevicesInfo(info: List<DeviceInfo>) {
|
||||
val entities = info.map {
|
||||
MyDeviceLastSeenInfoEntity(
|
||||
lastSeenTs = it.lastSeenTs,
|
||||
|
@ -105,7 +105,7 @@ object CryptoMapper {
|
||||
null
|
||||
}
|
||||
},
|
||||
firsTimeSeenLocalTs = deviceInfoEntity.firstTimeSeenLocalTs
|
||||
firstTimeSeenLocalTs = deviceInfoEntity.firstTimeSeenLocalTs
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context, privat
|
||||
deviceInfo.trustLevel = DeviceTrustLevel(crossSigningVerified = false, locallyVerified = false)
|
||||
|
||||
// can we get more info on this device?
|
||||
session?.cryptoService()?.getMyDeviceInfo()?.firstOrNull { it.deviceId == deviceId }?.let {
|
||||
session?.cryptoService()?.getMyDevicesInfo()?.firstOrNull { it.deviceId == deviceId }?.let {
|
||||
postAlert(context, userId, deviceId, true, deviceInfo, it)
|
||||
} ?: kotlin.run {
|
||||
postAlert(context, userId, deviceId, true, deviceInfo)
|
||||
|
@ -69,7 +69,7 @@ class UnknownDeviceDetectorSharedViewModel(
|
||||
|
||||
val currentSessionTs = session.cryptoService().getCryptoDeviceInfo(session.myUserId).firstOrNull {
|
||||
it.deviceId == session.sessionParams.credentials.deviceId
|
||||
}?.firsTimeSeenLocalTs ?: System.currentTimeMillis()
|
||||
}?.firstTimeSeenLocalTs ?: System.currentTimeMillis()
|
||||
Timber.v("## Detector - Current Session first time seen $currentSessionTs")
|
||||
|
||||
ignoredDeviceList.addAll(
|
||||
@ -94,7 +94,7 @@ class UnknownDeviceDetectorSharedViewModel(
|
||||
.filter { !ignoredDeviceList.contains(it.deviceId) }
|
||||
.sortedByDescending { it.lastSeenTs }
|
||||
.map { deviceInfo ->
|
||||
val deviceKnownSince = cryptoList.firstOrNull { it.deviceId == deviceInfo.deviceId }?.firsTimeSeenLocalTs ?: 0
|
||||
val deviceKnownSince = cryptoList.firstOrNull { it.deviceId == deviceInfo.deviceId }?.firstTimeSeenLocalTs ?: 0
|
||||
DeviceDetectionInfo(
|
||||
deviceInfo,
|
||||
deviceKnownSince > currentSessionTs + 60_000, // short window to avoid false positive,
|
||||
|
@ -58,7 +58,7 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
||||
var trusted: DeviceTrustLevel? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var e2Ecapable: Boolean = true
|
||||
var e2eCapable: Boolean = true
|
||||
|
||||
@EpoxyAttribute
|
||||
var legacyMode: Boolean = false
|
||||
@ -82,7 +82,7 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
||||
trusted
|
||||
)
|
||||
|
||||
if (e2Ecapable) {
|
||||
if (e2eCapable) {
|
||||
holder.trustIcon.setImageResource(shield)
|
||||
} else {
|
||||
holder.trustIcon.setImageDrawable(null)
|
||||
|
@ -99,7 +99,7 @@ class DevicesController @Inject constructor(private val errorFormatter: ErrorFor
|
||||
detailedMode(vectorPreferences.developerMode())
|
||||
deviceInfo(deviceInfo)
|
||||
currentDevice(true)
|
||||
e2Ecapable(true)
|
||||
e2eCapable(true)
|
||||
itemClickAction { callback?.onDeviceClicked(deviceInfo) }
|
||||
trusted(DeviceTrustLevel(currentSessionCrossTrusted, true))
|
||||
}
|
||||
@ -142,7 +142,7 @@ class DevicesController @Inject constructor(private val errorFormatter: ErrorFor
|
||||
deviceInfo(deviceInfo)
|
||||
currentDevice(false)
|
||||
itemClickAction { callback?.onDeviceClicked(deviceInfo) }
|
||||
e2Ecapable(cryptoInfo != null)
|
||||
e2eCapable(cryptoInfo != null)
|
||||
trusted(cryptoInfo?.trustLevel)
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<!-- BEGIN Strings added by Valere -->
|
||||
<string name="review_logins">Review where you’re logged in</string>
|
||||
<string name="verify_other_sessions">Verify your other sessions</string>
|
||||
<string name="verify_other_sessions">Verify all your sessions to ensure your account & messages are safe</string>
|
||||
<!-- END Strings added by Valere -->
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user