-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
add option to access original message #2125
Conversation
7944936
to
ce925dd
Compare
10123cb
to
a8fb946
Compare
114f0d5
to
89c644f
Compare
a62198d
to
05d21f2
Compare
@@ -854,7 +867,9 @@ async fn add_parts( | |||
} else { | |||
match ephemeral_timer { | |||
EphemeralTimer::Disabled => 0, | |||
EphemeralTimer::Enabled { duration } => rcvd_timestamp + i64::from(duration) | |||
EphemeralTimer::Enabled { duration } => { |
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 was rewritten by cargo fmt
, not sure why. it is not related to this pr.
mime_headers.clone() | ||
} else { | ||
None | ||
}, |
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.
we already had a field that was used for exactly the purpose of saving the raw mime message, although the name mime_headers
is a bit misleading - i meanwhile read it as "mime and headers" :)
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.
mime_headers
is misleading indeed. Is save_mime_headers
used for anything but debugging? Can it be removed?
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.
save_mime_headers
was introduced at deltachat/deltachat-core#388, not sure if it is actually in used, however, it is not much code, also, with this pr not even a wasted column anymore - so i would not remove it in this pr without further discussion.
pub fn simplify(mut input: String, is_chat_message: bool) -> (String, bool, Option<String>) { | ||
pub fn simplify(mut input: String, is_chat_message: bool) -> (String, bool, bool, Option<String>) { | ||
let mut is_cut = false; | ||
|
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.
yip, i also thought that four return values is a value to think over doing that in another way, however, i did not want to make this pr even larget - also, beside tests, simplify() us called only at one place, so i'd leave it as is for now :)
src/originalhtml.rs
Outdated
} else if mimetype == mime::TEXT_PLAIN { | ||
if let Ok(decoded_data) = mail.get_body() { | ||
self.plain = Some(decoded_data); | ||
self.format_flowed = |
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.
these parameter-getting lines are similar to the ones from mimeparser.rs, maybe we can move them to format_flowed.rs, however, as not much more code from format_flowed.rs is reusable (format_flowed.rs converts to plain text ignoring quotes where we want to convert to html and regard quotes), i think, it is not worth the noise.
I'm not sure if I agree calling it "dc_get_original_mime_html()" when It's clearly returning a modified version to work in browsers / converts text emails to html. Maybe "dc_get_original_mime_as_html()" would be a bit better? Anyways besides that minor naming and documentation wording stuff: |
…mime_modified-flag stays as-is, however
…handling for saved mime-structure
@Simon-Laux @link2xt i targeted most of your comments, thank you very much for that. moreover, i added a commit that explicitly avoid setting mime-modified- aka has-html-flag for encrypted messages. i'd like to handle/discuss that in a subsequent pr, there is probably no huge intersection between html-mails and encrypted-mails anyway. |
}; | ||
|
||
self.is_mime_modified = self.is_mime_modified | ||
|| ((is_forwarded || is_cut || top_quote.is_some()) |
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.
top_quote.is_some()
is not necessary. We display the top quote just fine, no reason to show "read more" for each unencrypted message with a quote. If we have removed User ... wrote:
top line, then is_cut
should be set. remove_top_quote
has an is_quoted_headline
variable internally which tracks this.
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.
i also thought over that bit.
we do that only for non-delta-messages anyway - and then, there is the risk that the quote is not really a quoted messages but sth. the user entered/edited manually, so a tap on the quote cannot go to the original message and there is no chance the see the full quote (in the message, only the first lines are shown)
this risk is potentially also there also for delta-to-delta communication, eg. if the message was deleted, however, it is much larger when the user can edit the quote manually.
so, i'd leave that in for now, it is better to show one "full message" button too much than one too few :)
let lines = split_lines(&self.text); | ||
|
||
let mut ret = | ||
"<!DOCTYPE html>\n<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><body>\n".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.
html
, head
, meta
and body
tags are all not necessary for valid HTML5 (identified by <!DOCTYPE html>
), could be removed.
At least, is meta
necessary here?
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.
without the meta-tag, some browsers do display utf-8 wrong, so yes, that is needed.
as <meta>
needs to be placed in <head>
i would also leave them in, it is just a few characters and i am not sure, if all browsers will handle things correctly when we rely on html5 here.
standard footers meanwhile go the "contact status", so they are no longer a reason to trigger "full message view". this was already discussed when the HTML view was introduced at #2125 however, forgotten to change when the "contact status" was added at #2218 this pr will result in a cleaner chat view with less "Show Full Message..." buttons and will also save some storage (in fact, i came over that when reviewing #4129 )
standard footers meanwhile go the "contact status", so they are no longer a reason to trigger "full message view". this was already discussed when the HTML view was introduced at #2125 however, forgotten to change when the "contact status" was added at #2218 this pr will result in a cleaner chat view with less "Show Full Message..." buttons and will also save some storage (in fact, i came over that when reviewing #4129 )
standard footers meanwhile go the "contact status", so they are no longer a reason to trigger "full message view". this was already discussed when the HTML view was introduced at #2125 however, forgotten to change when the "contact status" was added at #2218 this pr will result in a cleaner chat view with less "Show Full Message..." buttons and will also save some storage (in fact, i came over that when reviewing #4129 )
while dealing with email-compatibility (https://github.com/orgs/deltachat/projects/31 and also on one-to-one-talks), it turns out that we need an option to read the original message more urgently as i thought before.
therefore, the idea is to have a function to check if a message is "maybe bad" (
dc_msg_is_mime_modified()
dc_msg_has_html()
) and another function to get the message with "rich content", always as html (dc_get_original_mime_html()
dc_get_msg_html()
). the ui shall offer a button as "Show full message..." or so (there is already a pr for that on android). as the html-part is not shown and not even processed before the function is called, the fear or tracking seems to be already mitigated enough, however, for a first try, i do not want to make that too complicated - also, many html-mails are not really working without reading external content and you will not open "random" mails, but, as of now, only from senders you already started a chat with.having the option to access the "original" message, finallly also allows us to do handle the generated "short" mail more freely - eg. we can truncate long messages, and stop display before a links spanning 20 lines etc.
ui-wise, this is pretty easy to implement, and already done for android (deltachat/deltachat-android#1763 - there are also some images). desktop already has a similar hack, detecting such messages by scanning for "[...]" and offering a link to the info screen; this should be replaced by the api mentioned above.
open things: