mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Merge pull request #6520 from vector-im/feature/bca/stable_withheld
stable name for withheld
This commit is contained in:
commit
00c6ad58a5
1
changelog.d/5115.bugfix
Normal file
1
changelog.d/5115.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Stop using unstable names for withheld codes
|
@ -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
|
||||
@ -47,7 +46,6 @@ import org.matrix.android.sdk.mustFail
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.JVM)
|
||||
@LargeTest
|
||||
@Ignore
|
||||
class WithHeldTests : InstrumentedTest {
|
||||
|
||||
@get:Rule val rule = RetryTestRule(3)
|
||||
|
@ -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"
|
||||
const val 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)
|
||||
}
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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()) {
|
||||
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