mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
use specific unstable/stable class
This commit is contained in:
parent
d51a1fdb0e
commit
687c2794fd
@ -21,7 +21,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import org.junit.Assert
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
@ -87,7 +87,10 @@ object EventType {
|
||||
// Key share events
|
||||
const val ROOM_KEY_REQUEST = "m.room_key_request"
|
||||
const val FORWARDED_ROOM_KEY = "m.forwarded_room_key"
|
||||
val ROOM_KEY_WITHHELD = listOf("m.room_key.withheld", "org.matrix.room_key.withheld")
|
||||
val ROOM_KEY_WITHHELD = StableUnstableId(
|
||||
stable = "m.room_key.withheld",
|
||||
unstable = "org.matrix.room_key.withheld"
|
||||
)
|
||||
|
||||
const val REQUEST_SECRET = "m.secret.request"
|
||||
const val SEND_SECRET = "m.secret.send"
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.api.session.events.model
|
||||
|
||||
data class StableUnstableId(
|
||||
val stable: String,
|
||||
val unstable: String,
|
||||
) {
|
||||
val values = listOf(stable, unstable)
|
||||
}
|
@ -820,7 +820,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||
EventType.SEND_SECRET -> {
|
||||
onSecretSendReceived(event)
|
||||
}
|
||||
in EventType.ROOM_KEY_WITHHELD -> {
|
||||
in EventType.ROOM_KEY_WITHHELD.values -> {
|
||||
onKeyWithHeldReceived(event)
|
||||
}
|
||||
else -> {
|
||||
@ -869,7 +869,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||
senderKey = withHeldContent.senderKey,
|
||||
fromDevice = withHeldContent.fromDevice,
|
||||
event = Event(
|
||||
type = EventType.ROOM_KEY_WITHHELD.first(),
|
||||
type = EventType.ROOM_KEY_WITHHELD.stable,
|
||||
senderId = senderId,
|
||||
content = event.getClearContent()
|
||||
)
|
||||
|
@ -315,7 +315,7 @@ internal class IncomingKeyRequestManager @Inject constructor(
|
||||
)
|
||||
|
||||
val params = SendToDeviceTask.Params(
|
||||
EventType.ROOM_KEY_WITHHELD.first(),
|
||||
EventType.ROOM_KEY_WITHHELD.stable,
|
||||
MXUsersDevicesMap<Any>().apply {
|
||||
setObject(request.requestingUserId, request.requestingDeviceId, withHeldContent)
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ internal class MXMegolmEncryption(
|
||||
fromDevice = myDeviceId
|
||||
)
|
||||
val params = SendToDeviceTask.Params(
|
||||
EventType.ROOM_KEY_WITHHELD.first(),
|
||||
EventType.ROOM_KEY_WITHHELD.stable,
|
||||
MXUsersDevicesMap<Any>().apply {
|
||||
targets.forEach {
|
||||
setObject(it.userId, it.deviceId, withHeldContent)
|
||||
|
@ -117,7 +117,7 @@ internal open class OutgoingKeyRequestEntity(
|
||||
|
||||
private fun eventToResult(event: Event): RequestResult? {
|
||||
return when (event.getClearType()) {
|
||||
in EventType.ROOM_KEY_WITHHELD -> {
|
||||
in EventType.ROOM_KEY_WITHHELD.values -> {
|
||||
event.content.toModel<RoomKeyWithHeldContent>()?.code?.let {
|
||||
RequestResult.Failure(it)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user