Unsollicited response on APPEND was wrong, upgrade imap-flow to fix LITERAL+

This commit is contained in:
Quentin 2024-02-20 13:24:42 +01:00
parent 28b1f4f14d
commit 64b474f682
Signed by: quentin
GPG key ID: E9602264D639FF68
3 changed files with 16 additions and 13 deletions

6
Cargo.lock generated
View file

@ -1869,7 +1869,7 @@ dependencies = [
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project-lite 0.2.13", "pin-project-lite 0.2.13",
"socket2 0.5.5", "socket2 0.4.10",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -1980,13 +1980,15 @@ dependencies = [
[[package]] [[package]]
name = "imap-flow" name = "imap-flow"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/superboum/imap-flow.git?branch=custom/aerogramme#60ff9e082ccfcd10a042b616d8038a578fa0c8ff" source = "git+https://github.com/superboum/imap-flow.git?branch=custom/aerogramme#2bea066da1e09ad04bb5fb71b0dd8d6e5d9e3d19"
dependencies = [ dependencies = [
"bounded-static", "bounded-static",
"bytes", "bytes",
"imap-codec", "imap-codec",
"imap-types",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
] ]
[[package]] [[package]]

View file

@ -549,6 +549,8 @@ impl<'a> AuthenticatedContext<'a> {
)) ))
} }
//@FIXME we should write a specific version for the "selected" state
//that returns some unsollicited responses
async fn append( async fn append(
self, self,
mailbox: &MailboxCodec<'a>, mailbox: &MailboxCodec<'a>,
@ -560,10 +562,9 @@ impl<'a> AuthenticatedContext<'a> {
match self.append_internal(mailbox, flags, date, message).await { match self.append_internal(mailbox, flags, date, message).await {
Ok((_mb_view, unsollicited, uidvalidity, uid, _modseq)) => Ok(( Ok((_mb_view, uidvalidity, uid, _modseq)) => Ok((
Response::build() Response::build()
.tag(append_tag) .tag(append_tag)
.set_body(unsollicited)
.message("APPEND completed") .message("APPEND completed")
.code(Code::Other(CodeOther::unvalidated( .code(Code::Other(CodeOther::unvalidated(
format!("APPENDUID {} {}", uidvalidity, uid).into_bytes(), format!("APPENDUID {} {}", uidvalidity, uid).into_bytes(),
@ -603,7 +604,7 @@ impl<'a> AuthenticatedContext<'a> {
flags: &[Flag<'a>], flags: &[Flag<'a>],
date: &Option<DateTime>, date: &Option<DateTime>,
message: &Literal<'a>, message: &Literal<'a>,
) -> Result<(MailboxView, Vec<Body<'static>>, ImapUidvalidity, ImapUid, ModSeq)> { ) -> Result<(MailboxView, ImapUidvalidity, ImapUid, ModSeq)> {
let name: &str = MailboxName(mailbox).try_into()?; let name: &str = MailboxName(mailbox).try_into()?;
let mb_opt = self.user.open_mailbox(&name).await?; let mb_opt = self.user.open_mailbox(&name).await?;
@ -623,9 +624,9 @@ impl<'a> AuthenticatedContext<'a> {
// TODO: filter allowed flags? ping @Quentin // TODO: filter allowed flags? ping @Quentin
let (uidvalidity, uid, modseq) = view.internal.mailbox.append(msg, None, &flags[..]).await?; let (uidvalidity, uid, modseq) = view.internal.mailbox.append(msg, None, &flags[..]).await?;
let unsollicited = view.update(UpdateParameters::default()).await?; //let unsollicited = view.update(UpdateParameters::default()).await?;
Ok((view, unsollicited, uidvalidity, uid, modseq)) Ok((view, uidvalidity, uid, modseq))
} }
} }

View file

@ -185,15 +185,15 @@ impl NetLoop {
} }
async fn new(ctx: ClientContext, sock: AnyStream) -> Result<Self> { async fn new(ctx: ClientContext, sock: AnyStream) -> Result<Self> {
let mut opts = ServerFlowOptions::default();
opts.crlf_relaxed = false;
opts.literal_accept_text = Text::unvalidated("OK");
opts.literal_reject_text = Text::unvalidated("Literal rejected");
// Send greeting // Send greeting
let (server, _) = ServerFlow::send_greeting( let (server, _) = ServerFlow::send_greeting(
sock, sock,
ServerFlowOptions { opts,
crlf_relaxed: false,
literal_accept_text: Text::unvalidated("OK"),
literal_reject_text: Text::unvalidated("Literal rejected"),
..ServerFlowOptions::default()
},
Greeting::ok( Greeting::ok(
Some(Code::Capability(ctx.server_capabilities.to_vec())), Some(Code::Capability(ctx.server_capabilities.to_vec())),
"Aerogramme", "Aerogramme",