Don't display reply/forwarding prefixes in notifications: Closes #6121
This also properly strips both Re: and Fwd: prefixes, even when stacked up, in the conversation list.
This commit is contained in:
parent
8e43a9c080
commit
6d1010abdd
5 changed files with 45 additions and 21 deletions
|
|
@ -319,10 +319,6 @@ public class Geary.Email : BaseObject {
|
|||
public string get_preview_as_string() {
|
||||
return (preview != null) ? preview.buffer.to_string() : "";
|
||||
}
|
||||
|
||||
public string get_subject_as_string() {
|
||||
return (subject != null) ? subject.value : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary originator of an email, which is defined as the first mailbox address
|
||||
|
|
|
|||
|
|
@ -214,6 +214,38 @@ public class Geary.RFC822.Subject : Geary.MessageData.StringMessageData,
|
|||
value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Subject: line stripped of reply and forwarding prefixes.
|
||||
*
|
||||
* Strips ''all'' prefixes, meaning "Re: Fwd: Soup's on!" will return "Soup's on!"
|
||||
*
|
||||
* Returns an empty string if the Subject: line is empty (or is empty after stripping prefixes).
|
||||
*/
|
||||
public string strip_prefixes() {
|
||||
string subject_base = original;
|
||||
bool changed = false;
|
||||
do {
|
||||
string stripped;
|
||||
try {
|
||||
Regex re_regex = new Regex("^(?i:Re:\\s*)+");
|
||||
stripped = re_regex.replace(subject_base, -1, 0, "");
|
||||
|
||||
Regex fwd_regex = new Regex("^(?i:Fwd:\\s*)+");
|
||||
stripped = fwd_regex.replace(stripped, -1, 0, "");
|
||||
} catch (RegexError e) {
|
||||
debug("Failed to clean up subject line \"%s\": %s", original, e.message);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
changed = (stripped != subject_base);
|
||||
if (changed)
|
||||
subject_base = stripped;
|
||||
} while (changed);
|
||||
|
||||
return String.reduce_whitespace(subject_base);
|
||||
}
|
||||
|
||||
/**
|
||||
* See Geary.MessageData.SearchableMessageData.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue