melib/list_management: don't ignore "NO" in List-Post
parent
1ddde400ee
commit
b0e50a29bd
|
@ -25,10 +25,12 @@ use super::Envelope;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
|
|
||||||
#[derive(Debug, Copy)]
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||||
pub enum ListAction<'a> {
|
pub enum ListAction<'a> {
|
||||||
Url(&'a [u8]),
|
Url(&'a [u8]),
|
||||||
Email(&'a [u8]),
|
Email(&'a [u8]),
|
||||||
|
///`List-Post` field may contain the special value "NO".
|
||||||
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a [u8]> for ListAction<'a> {
|
impl<'a> From<&'a [u8]> for ListAction<'a> {
|
||||||
|
@ -38,6 +40,8 @@ impl<'a> From<&'a [u8]> for ListAction<'a> {
|
||||||
* parser::mailto() will handle this if user tries to unsubscribe.
|
* parser::mailto() will handle this if user tries to unsubscribe.
|
||||||
*/
|
*/
|
||||||
ListAction::Email(value)
|
ListAction::Email(value)
|
||||||
|
} else if value.starts_with(b"NO") {
|
||||||
|
ListAction::No
|
||||||
} else {
|
} else {
|
||||||
/* Otherwise treat it as url. There's no foolproof way to check if this is valid, so
|
/* Otherwise treat it as url. There's no foolproof way to check if this is valid, so
|
||||||
* postpone it until we try an HTTP request.
|
* postpone it until we try an HTTP request.
|
||||||
|
@ -69,15 +73,6 @@ impl<'a> ListAction<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Clone for ListAction<'a> {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
match self {
|
|
||||||
ListAction::Url(a) => ListAction::Url(<&[u8]>::clone(a)),
|
|
||||||
ListAction::Email(a) => ListAction::Email(<&[u8]>::clone(a)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct ListActions<'a> {
|
pub struct ListActions<'a> {
|
||||||
pub id: Option<&'a str>,
|
pub id: Option<&'a str>,
|
||||||
|
@ -129,6 +124,11 @@ impl<'a> ListActions<'a> {
|
||||||
|
|
||||||
if let Some(post) = envelope.other_headers().get("List-Post") {
|
if let Some(post) = envelope.other_headers().get("List-Post") {
|
||||||
ret.post = ListAction::parse_options_list(post.as_bytes());
|
ret.post = ListAction::parse_options_list(post.as_bytes());
|
||||||
|
if let Some(ref l) = ret.post {
|
||||||
|
if l.starts_with(&[ListAction::No]) {
|
||||||
|
ret.post = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(unsubscribe) = envelope.other_headers().get("List-Unsubscribe") {
|
if let Some(unsubscribe) = envelope.other_headers().get("List-Unsubscribe") {
|
||||||
|
|
|
@ -1175,7 +1175,7 @@ pub mod mailing_lists {
|
||||||
map(tag("NO"), |_| ()),
|
map(tag("NO"), |_| ()),
|
||||||
map(opt(cfws), |_| ()),
|
map(opt(cfws), |_| ()),
|
||||||
),
|
),
|
||||||
|_| vec![],
|
|_| vec![&b"NO"[..]],
|
||||||
),
|
),
|
||||||
))(input)?;
|
))(input)?;
|
||||||
let (input, _) = opt(cfws)(input)?;
|
let (input, _) = opt(cfws)(input)?;
|
||||||
|
|
|
@ -223,6 +223,17 @@ impl MailView {
|
||||||
if let Ok(Some(bytes_result)) = try_recv_timeout!(&mut chan) {
|
if let Ok(Some(bytes_result)) = try_recv_timeout!(&mut chan) {
|
||||||
match bytes_result {
|
match bytes_result {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
|
if account
|
||||||
|
.collection
|
||||||
|
.get_env(self.coordinates.2)
|
||||||
|
.other_headers()
|
||||||
|
.is_empty()
|
||||||
|
{
|
||||||
|
let _ = account
|
||||||
|
.collection
|
||||||
|
.get_env_mut(self.coordinates.2)
|
||||||
|
.populate_headers(&bytes);
|
||||||
|
}
|
||||||
let body = AttachmentBuilder::new(&bytes).build();
|
let body = AttachmentBuilder::new(&bytes).build();
|
||||||
let body_text = self.attachment_to_text(&body, context);
|
let body_text = self.attachment_to_text(&body, context);
|
||||||
self.state = MailViewState::Loaded {
|
self.state = MailViewState::Loaded {
|
||||||
|
@ -1116,6 +1127,17 @@ impl Component for MailView {
|
||||||
debug!("bytes_result");
|
debug!("bytes_result");
|
||||||
match bytes_result {
|
match bytes_result {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
|
if context.accounts[&self.coordinates.0]
|
||||||
|
.collection
|
||||||
|
.get_env(self.coordinates.2)
|
||||||
|
.other_headers()
|
||||||
|
.is_empty()
|
||||||
|
{
|
||||||
|
let _ = context.accounts[&self.coordinates.0]
|
||||||
|
.collection
|
||||||
|
.get_env_mut(self.coordinates.2)
|
||||||
|
.populate_headers(&bytes);
|
||||||
|
}
|
||||||
let body = AttachmentBuilder::new(&bytes).build();
|
let body = AttachmentBuilder::new(&bytes).build();
|
||||||
let body_text = self.attachment_to_text(&body, context);
|
let body_text = self.attachment_to_text(&body, context);
|
||||||
self.state = MailViewState::Loaded {
|
self.state = MailViewState::Loaded {
|
||||||
|
@ -1693,6 +1715,7 @@ impl Component for MailView {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
list_management::ListAction::No => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue