mirror of
https://gitlab.com/mailcat-devs/mailcat.git
synced 2025-12-21 04:23:27 +01:00
Use mime crate
This commit is contained in:
parent
e046318a2e
commit
19981b4671
3 changed files with 13 additions and 4 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use mailparse::{DispositionType, MailParseError, ParsedMail};
|
||||
use mailparse::{DispositionType, ParsedMail};
|
||||
|
||||
pub trait ParsedMailEx {
|
||||
fn is_attachment(&self) -> bool;
|
||||
|
||||
fn get_body_text(&self) -> Result<Option<String>, MailParseError>;
|
||||
fn get_body_text(&self) -> Result<Option<String>, anyhow::Error>;
|
||||
}
|
||||
|
||||
impl<'a> ParsedMailEx for ParsedMail<'a> {
|
||||
|
|
@ -11,11 +11,12 @@ impl<'a> ParsedMailEx for ParsedMail<'a> {
|
|||
self.get_content_disposition().disposition == DispositionType::Attachment
|
||||
}
|
||||
|
||||
fn get_body_text(&self) -> Result<Option<String>, MailParseError> {
|
||||
fn get_body_text(&self) -> Result<Option<String>, anyhow::Error> {
|
||||
let mimetype: mime::Mime = self.ctype.mimetype.parse()?;
|
||||
if self.is_attachment() {
|
||||
return Ok(None);
|
||||
}
|
||||
if self.ctype.mimetype == "text/plain" {
|
||||
if mimetype == mime::TEXT_PLAIN {
|
||||
return Ok(Some(self.get_body()?));
|
||||
}
|
||||
for subpart in &self.subparts {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue