@@ -158,38 +158,38 @@ pub struct DecryptedRoomEvent {
158
158
#[ wasm_bindgen( readonly) ]
159
159
pub event : JsString ,
160
160
161
- encryption_info : Option < EncryptionInfo > ,
161
+ encryption_info : EncryptionInfo ,
162
162
}
163
163
164
164
#[ wasm_bindgen]
165
165
impl DecryptedRoomEvent {
166
166
/// The user ID of the event sender, note this is untrusted data
167
167
/// unless the `verification_state` is as well trusted.
168
168
#[ 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 ( )
171
171
}
172
172
173
173
/// The device ID of the device that sent us the event, note this
174
174
/// is untrusted data unless `verification_state` is as well
175
175
/// trusted.
176
176
#[ wasm_bindgen( getter, js_name = "senderDevice" ) ]
177
177
pub fn sender_device ( & self ) -> Option < identifiers:: DeviceId > {
178
- self . encryption_info . as_ref ( ) ? . sender_device . clone ( )
178
+ self . encryption_info . sender_device . clone ( )
179
179
}
180
180
181
181
/// The Curve25519 key of the device that created the megolm
182
182
/// decryption key originally.
183
183
#[ 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 ( )
186
186
}
187
187
188
188
/// The signing Ed25519 key that have created the megolm key that
189
189
/// was used to decrypt this session.
190
190
#[ wasm_bindgen( getter, js_name = "senderClaimedEd25519Key" ) ]
191
191
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 ( ) )
193
193
}
194
194
195
195
/// Returns an empty array
@@ -210,23 +210,19 @@ impl DecryptedRoomEvent {
210
210
/// decryption. It may change in the future if a device gets
211
211
/// verified or deleted.
212
212
#[ 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)
215
215
}
216
216
}
217
217
218
- impl TryFrom < matrix_sdk_common:: deserialized_responses:: TimelineEvent > for DecryptedRoomEvent {
218
+ impl TryFrom < matrix_sdk_common:: deserialized_responses:: DecryptedRoomEvent > for DecryptedRoomEvent {
219
219
type Error = UnsupportedAlgorithmError ;
220
220
221
221
fn try_from (
222
- value : matrix_sdk_common:: deserialized_responses:: TimelineEvent ,
222
+ value : matrix_sdk_common:: deserialized_responses:: DecryptedRoomEvent ,
223
223
) -> Result < Self , Self :: Error > {
224
- let encryption_info = match value. encryption_info ( ) {
225
- None => None ,
226
- Some ( encryption_info) => Some ( encryption_info. clone ( ) . try_into ( ) ?) ,
227
- } ;
228
-
229
- Ok ( Self { event : value. raw ( ) . json ( ) . get ( ) . to_owned ( ) . into ( ) , encryption_info } )
224
+ let encryption_info = value. encryption_info . clone ( ) . try_into ( ) ?;
225
+ Ok ( Self { event : value. event . json ( ) . get ( ) . into ( ) , encryption_info } )
230
226
}
231
227
}
232
228
0 commit comments