@@ -388,15 +388,15 @@ pub enum ProcessedToDeviceEventType {
388
388
#[ wasm_bindgen]
389
389
#[ derive( Debug , Clone ) ]
390
390
pub struct DecryptedToDeviceEvent {
391
- /// A JSON-encoded object containing the decrypted event, as if it had been
392
- /// sent in the clear .
391
+ /// The decrypted event, as if it had been sent in the clear, encoded as
392
+ /// JSON .
393
393
///
394
394
/// Typically contains properties `type`, `sender` and `content`.
395
395
///
396
396
/// (For room keys or secrets, some part of the content might have been
397
397
/// zeroized).
398
- #[ wasm_bindgen( readonly, getter_with_clone, js_name = "decryptedRawEvent " ) ]
399
- pub decrypted_raw_event : JsString ,
398
+ #[ wasm_bindgen( readonly, getter_with_clone, js_name = "rawEvent " ) ]
399
+ pub raw_event : JsString ,
400
400
401
401
/// The encryption information for the event.
402
402
#[ wasm_bindgen( readonly, getter_with_clone, js_name = "encryptionInfo" ) ]
@@ -417,8 +417,8 @@ impl DecryptedToDeviceEvent {
417
417
#[ wasm_bindgen]
418
418
#[ derive( Debug , Clone ) ]
419
419
pub struct PlainTextToDeviceEvent {
420
- /// A JSON-encoded object containing the Matrix to-device message with
421
- /// `type`, `sender` and `content` fields .
420
+ /// The to-device message, containing `type`, `sender` and `content` fields,
421
+ /// encoded as JSON .
422
422
#[ wasm_bindgen( readonly, getter_with_clone, js_name = "rawEvent" ) ]
423
423
pub raw_event : JsString ,
424
424
}
@@ -437,10 +437,10 @@ impl PlainTextToDeviceEvent {
437
437
#[ wasm_bindgen]
438
438
#[ derive( Debug , Clone ) ]
439
439
pub struct UTDToDeviceEvent {
440
- /// A JSON-encoded object containing the original message of type
441
- /// `m.room.encrypted` that failed to be decrypted .
442
- #[ wasm_bindgen( readonly, getter_with_clone, js_name = "wireEvent " ) ]
443
- pub wire_event : JsString ,
440
+ /// The original message ( of type `m.room.encrypted`) that failed to be
441
+ /// decrypted, encoded as JSON .
442
+ #[ wasm_bindgen( readonly, getter_with_clone, js_name = "rawEvent " ) ]
443
+ pub raw_event : JsString ,
444
444
// TODO: Add some OlmError in the future
445
445
}
446
446
@@ -459,10 +459,9 @@ impl UTDToDeviceEvent {
459
459
#[ wasm_bindgen]
460
460
#[ derive( Debug , Clone ) ]
461
461
pub struct InvalidToDeviceEvent {
462
- /// A JSON-encoded object containing the original message as received from
463
- /// sync.
464
- #[ wasm_bindgen( readonly, getter_with_clone, js_name = "wireEvent" ) ]
465
- pub wire_event : JsString ,
462
+ /// The original message as received from sync, encoded as JSON.
463
+ #[ wasm_bindgen( readonly, getter_with_clone, js_name = "rawEvent" ) ]
464
+ pub raw_event : JsString ,
466
465
// TODO: Add some error information here?
467
466
}
468
467
@@ -498,11 +497,10 @@ pub fn processed_to_device_event_to_js_value(
498
497
let result = match processed_to_device_event {
499
498
matrix_sdk_crypto:: types:: ProcessedToDeviceEvent :: Decrypted { raw, encryption_info } => {
500
499
match encryption_info. try_into ( ) {
501
- Ok ( encryption_info) => DecryptedToDeviceEvent {
502
- decrypted_raw_event : raw. json ( ) . get ( ) . into ( ) ,
503
- encryption_info ,
500
+ Ok ( encryption_info) => {
501
+ DecryptedToDeviceEvent { raw_event : raw. json ( ) . get ( ) . into ( ) , encryption_info }
502
+ . into ( )
504
503
}
505
- . into ( ) ,
506
504
Err ( e) => {
507
505
// This can only happen if we receive an encrypted to-device event which is
508
506
// encrypted with an algorithm we don't recognise. This
@@ -516,13 +514,13 @@ pub fn processed_to_device_event_to_js_value(
516
514
}
517
515
}
518
516
matrix_sdk_crypto:: types:: ProcessedToDeviceEvent :: UnableToDecrypt ( utd) => {
519
- UTDToDeviceEvent { wire_event : utd. json ( ) . get ( ) . into ( ) } . into ( )
517
+ UTDToDeviceEvent { raw_event : utd. json ( ) . get ( ) . into ( ) } . into ( )
520
518
}
521
519
matrix_sdk_crypto:: types:: ProcessedToDeviceEvent :: PlainText ( plain) => {
522
520
PlainTextToDeviceEvent { raw_event : plain. json ( ) . get ( ) . into ( ) } . into ( )
523
521
}
524
522
matrix_sdk_crypto:: types:: ProcessedToDeviceEvent :: Invalid ( invalid) => {
525
- InvalidToDeviceEvent { wire_event : invalid. json ( ) . get ( ) . into ( ) } . into ( )
523
+ InvalidToDeviceEvent { raw_event : invalid. json ( ) . get ( ) . into ( ) } . into ( )
526
524
}
527
525
} ;
528
526
Some ( result)
0 commit comments