refactor: Start to use imap-codec. #223
No reviewers
Labels
No Label
IMAP
JMAP
Maildir
Retired
User Experience
User Interface
bsd
bug
contacts
currently worked on
documentation
duplicate
easy
enhancement
help wanted
invalid
linux-gnu
macos
mbox
notmuch
question
security
wishlist
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: meli/meli#223
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "duesee/meli:duesee/use_imap_codec"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
This PR introduces imap-codec to meli. I intended to replace all
send_command
instances, but there are a few remainig ones where I don't fully understand what should happen :-)Can someone take a look and tell me what they think? There are a few
TODO
s that I put on my imap-codec list to make things more pleasant.Also, there seems to be a bug because imap-codec complains that we try to send a
UID == 0
.On a positive side: I think this may fix some instances where literals were not handled before. At least it appeared to me that it could happen that values are encoded as quoted strings, although we need to use literals.
I will work on my setup and try to test this better.
65578b06bb
to82787ced43
82787ced43
to6dfb03aaa6
WIP: refactor: Start to use imap-codec.to refactor: Start to use imap-codec.refactor: Start to use imap-codec.to WIP: refactor: Start to use imap-codec.I love how tidy and clean this looks :) Didn't test it yet though, does it work/compile?
@ -237,1 +250,3 @@
}
format!("1:{}", max_uid)
};
self.send_command_imap_codec(CommandBody::fetch(
Is it okay if we use sequences here instead of UID?
@ -687,1 +706,3 @@
.await?;
self.send_command_imap_codec(CommandBody::status(
mailbox_path,
vec![StatusAttribute::UidNext],
this could probably be a slice
&[StatusAttribute]
unlessCommandBody::status
needs the allocationNext version :-) https://github.com/duesee/imap-codec/issues/240 Can I add a TODO and resolve this in the next release?
@ -90,3 +96,3 @@
self.uid_store.msn_index.lock().unwrap().get(&mailbox_hash)
);
self.send_command("UID SEARCH 1:*".as_bytes()).await?;
self.send_command_imap_codec(CommandBody::search(
Again same question about uid<->sequence
@ -216,16 +260,20 @@ crate::declare_u64_hash!(EnvelopeHash);
/// bytes into an `Attachment` object.
#[derive(Clone, Serialize, Deserialize)]
pub struct Envelope {
pub hash: EnvelopeHash,
Hm yeah. What if we made an IMAPEnvelope type we can convert into Envelopes? Envelope -> ImapEnvelope would be lossy though, if the header map is not included.
Sounds good to me.
I played a bit with response handling but it just occured to me that we could do this in a later PR as it's not really required when replacing the "sending side". Shall we first try to get the sending side in, i.e, fully replace
send_command
and tackle responses later?Ofc ofc
@ -167,2 +175,4 @@
}
impl Flag {
// TODO: Remove this eventually.
Since imap-backend is a feature, we can make an imap specific trait that Flag implements if the feature is enabled
@ -169,0 +179,4 @@
pub(crate) fn derive_imap_codec_flags(&self) -> Vec<ImapCodecFlag> {
let mut flags = Vec::new();
if self.is_passed() {
Passed is from maildir http://cr.yp.to/proto/maildir.html
So not really meaningful in IMAP, it's there for legacy when parsing maildir and ignored in general.
It compiles and seems to work a bit better with the fake-mail-server -- not sure if that's a good or bad sign :D -- because meli now shows some mails it didn't before. But I need to debug an X.509 issue first in order to test with dovecot/courier/... Will try on monday :-)
Had a bit time today and can use meli with a local Courier now :-)
Can't say for sure if everything is working as expected because it appears to me that there could be a bug. When I create a draft, and edit it, it seems that the body of the new draft is "merged" with the content of the old one.
But this happens on
master
, too. So I don't see any difference betweenmaster
andduesee/use_imap_codec
in this regard.6dfb03aaa6
tod22c00913f
WIP: refactor: Start to use imap-codec.to refactor: Start to use imap-codec.d22c00913f
toa907f18667
I think this is ready to go :-) I don't really know what is supposed to work and what not but can't see a difference between master and this branch. So, while I don't feel too confident on this PR, I think it should be fine :-)
8763ee23ee
tof72056e6f1
f72056e6f1
tod58676292a
@ -39,6 +39,20 @@ use std::{
};
use futures::io::{AsyncReadExt, AsyncWriteExt};
#[cfg(feature = "deflate_compression")]
Previously,
CompressionAlgorithm
wasn't feature-gated. This is change 1/2.@ -501,3 +505,3 @@
}
pub async fn send_command(&mut self, command: &[u8]) -> Result<()> {
pub async fn send_command(&mut self, body: CommandBody<'_>) -> Result<()> {
This is change 2/2. I reworked this method a bit. Notably, it now has the
flush
.d58676292a
to4da5366959