Skip to content

Commit 65dd03b

Browse files
committed
Remove redundant Option on DecryptedRoomEvent::encryption_info
There is now no way for this to be `None`.
1 parent 49a8644 commit 65dd03b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
the same event successfully decrypted.
2121
([#236](https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/pull/236))
2222

23+
- A number of the properties and methods on `DecryptedRoomEvent` no longer return `undefined`
24+
([#243](https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/pull/243))
25+
2326
# matrix-sdk-crypto-wasm v14.2.1
2427

2528
Update matrix-sdk-crypto to `0.11.1`, which includes:

src/responses.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,38 +158,38 @@ pub struct DecryptedRoomEvent {
158158
#[wasm_bindgen(readonly)]
159159
pub event: JsString,
160160

161-
encryption_info: Option<EncryptionInfo>,
161+
encryption_info: EncryptionInfo,
162162
}
163163

164164
#[wasm_bindgen]
165165
impl DecryptedRoomEvent {
166166
/// The user ID of the event sender, note this is untrusted data
167167
/// unless the `verification_state` is as well trusted.
168168
#[wasm_bindgen(getter)]
169-
pub fn sender(&self) -> Option<identifiers::UserId> {
170-
Some(self.encryption_info.as_ref()?.sender.clone())
169+
pub fn sender(&self) -> identifiers::UserId {
170+
self.encryption_info.sender.clone()
171171
}
172172

173173
/// The device ID of the device that sent us the event, note this
174174
/// is untrusted data unless `verification_state` is as well
175175
/// trusted.
176176
#[wasm_bindgen(getter, js_name = "senderDevice")]
177177
pub fn sender_device(&self) -> Option<identifiers::DeviceId> {
178-
self.encryption_info.as_ref()?.sender_device.clone()
178+
self.encryption_info.sender_device.clone()
179179
}
180180

181181
/// The Curve25519 key of the device that created the megolm
182182
/// decryption key originally.
183183
#[wasm_bindgen(getter, js_name = "senderCurve25519Key")]
184-
pub fn sender_curve25519_key(&self) -> Option<JsString> {
185-
Some(self.encryption_info.as_ref()?.sender_curve25519_key_base64.as_str().into())
184+
pub fn sender_curve25519_key(&self) -> String {
185+
self.encryption_info.sender_curve25519_key_base64.as_str().to_owned()
186186
}
187187

188188
/// The signing Ed25519 key that have created the megolm key that
189189
/// was used to decrypt this session.
190190
#[wasm_bindgen(getter, js_name = "senderClaimedEd25519Key")]
191191
pub fn sender_claimed_ed25519_key(&self) -> Option<JsString> {
192-
Some(self.encryption_info.as_ref()?.sender_claimed_ed25519_key.as_ref()?.as_str().into())
192+
Some(self.encryption_info.sender_claimed_ed25519_key.as_ref()?.as_str().into())
193193
}
194194

195195
/// Returns an empty array
@@ -210,8 +210,8 @@ impl DecryptedRoomEvent {
210210
/// decryption. It may change in the future if a device gets
211211
/// verified or deleted.
212212
#[wasm_bindgen(js_name = "shieldState")]
213-
pub fn shield_state(&self, strict: bool) -> Option<encryption::ShieldState> {
214-
Some(self.encryption_info.as_ref()?.shield_state(strict))
213+
pub fn shield_state(&self, strict: bool) -> encryption::ShieldState {
214+
self.encryption_info.shield_state(strict)
215215
}
216216
}
217217

@@ -221,7 +221,7 @@ impl TryFrom<matrix_sdk_common::deserialized_responses::DecryptedRoomEvent> for
221221
fn try_from(
222222
value: matrix_sdk_common::deserialized_responses::DecryptedRoomEvent,
223223
) -> Result<Self, Self::Error> {
224-
let encryption_info = Some(value.encryption_info.clone().try_into()?);
224+
let encryption_info = value.encryption_info.clone().try_into()?;
225225
Ok(Self { event: value.event.json().get().into(), encryption_info })
226226
}
227227
}

0 commit comments

Comments
 (0)