-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(crypto): Add optional withheld reason to UnableToDecryptReason
#4305
Conversation
9abe4ba
to
ea5fcdb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4305 +/- ##
==========================================
- Coverage 85.15% 85.11% -0.05%
==========================================
Files 280 280
Lines 30826 30837 +11
==========================================
- Hits 26251 26248 -3
- Misses 4575 4589 +14 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a sensible direction to me; a few comments though
Mostly I'd like to know if we can avoid introducing yet another type
// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of | ||
// this crate. Used for string enums because their `_Custom` variant can't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot be used in a meaningful way outside of this crate
It's used in matrix-sdk-crypto
, so that doesn't seem right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that seems like a copy-paste error.
Perhaps we should just remove that line.
// XXX had to make the field public to make ruma `StringEnum` macro happy. | ||
pub struct PrivOwnedStr(pub Box<str>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes nothing makes sense with the struct anymore (the name, the doc, ..)
Not sure how to properly document it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Ruma macro expects the type to have this name, it's not something that is in under our control...
The alternatives are to not use the Ruma macro or to have multiple copies of this struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fair enough. It would be helpful if this could be explained in a comment.
Why does this need to be pub
, when it didn't need to be pub
when it lived in the crypto crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when it didn't need to be pub when it lived in the crypto crate
Because it is also used by other enums (still in crypto) that now uses the one that is in common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there was another copy left 2151fcd
I would be ok to revert that and have multiple copies if it makes it simpler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be pub, when it didn't need to be pub when it lived in the crypto crate?
Because otherwise you can't construct the variant outside of the crate where the type lives unless it's pub. Now I don't exactly know where that is needed but if we remove the pub the compiler might tell us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For EventEncryptionAlgorithm
error[E0616]: field `0` of struct `matrix_sdk_common::deserialized_responses::PrivOwnedStr` is private
--> crates/matrix-sdk-crypto/src/types/mod.rs:430:49
|
430 | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
| ^^^^^^^^^^ private field
|
= note: this error originates in the derive macro `StringEnum` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0423]: cannot initialize a tuple struct which contains private fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now, with the exception of PrivOwnedStr, for which I defer to @poljar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a small nit, I think the rest looks good.
// XXX had to make the field public to make ruma `StringEnum` macro happy. | ||
pub struct PrivOwnedStr(pub Box<str>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Ruma macro expects the type to have this name, it's not something that is in under our control...
The alternatives are to not use the Ruma macro or to have multiple copies of this struct.
// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of | ||
// this crate. Used for string enums because their `_Custom` variant can't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that seems like a copy-paste error.
Perhaps we should just remove that line.
2151fcd
to
8f8cd17
Compare
Adds new UtdCause variants for withheld keys, enabling applications to display customised messages when an Unable-To-Decrypt message is expected. refactor(crypto): Move WithheldCode from crypto to common crate
f09b3e4
to
6801811
Compare
Fixes #4270
Signed-off-by: