use crate::message::clean;
pub fn new_mail(from: &str, subject: &str) {
let _ = notify_rust::Notification::new()
.summary(¬ification_text(from))
.body(¬ification_text(subject))
.appname("Postvak")
.show();
}
pub fn escape_markup(text: &str) -> String {
text.replace('&', "&")
.replace('<', "<")
.replace('>', ">")
}
fn notification_text(text: &str) -> String {
let text = clean(text, false);
if cfg!(target_os = "linux") {
escape_markup(&text)
} else {
text
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn escape_markup_escapes_tags_and_entities() {
assert_eq!(
escape_markup("<b>Tom & Jerry</b>"),
"<b>Tom & Jerry</b>"
);
}
}