-
Notifications
You must be signed in to change notification settings - Fork 1
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: MimeMessage: Support extra Content-Type directives #6
Conversation
@link2xt, which branch should i merge this to, not to break the current versions of DC? Do we have an elaborated procedure for that? |
Support extra "Content-Type" directives in MimeMessage passed in a fake "Content-Type-Deltachat-Directives" header which is then removed from the resulting message. This is needed to support adding "protected-headers=\"v1\"" directive to the "Content-Type" header of multipart messages.
428cfa6
to
347dfa9
Compare
Why would it break existing version? Isn't the change backwards-compatible if nobody sets this header? There is basically only the |
let mut ct_value: String; | ||
if let Some(message_type) = self.message_type { | ||
// Use `message_type` as `Content-Type` if present | ||
ct_value = message_type.to_string(); |
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.
@link2xt you're right, it's backward-compatible, we even never get here if self.children.len() == 0
}; | ||
} | ||
if let Some(directives) = self.headers.get("Content-Type-Deltachat-Directives".to_string()) { | ||
let directives: String = directives.get_value().unwrap(); |
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.
This unwrap
looks a bit scary, but FromHeader
for String
never returns error and there is a similar pattern in other places of the code, so it's ok. Could still wrap this into if let Ok(..)
for extra safety, dealing with panics especially on mobile is hard, better avoid them when we can.
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.
This function already did the same for "Content-Type" header, so i decided not to change this right now. But i agree that better to refactor this
Support extra "Content-Type" directives in MimeMessage passed in a fake "Content-Type-Deltachat-Directives" header which is then removed from the resulting message. This is needed to support adding "protected-headers="v1"" directive to the "Content-Type" header of multipart messages.
This is related to deltachat/deltachat-core-rust#2302