Commit Graph

1136 Commits

Author SHA1 Message Date
Manos Pitsidianakis
2429f17b44
melib/jmap: on invalid conf value, print what value is expected
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-07-11 09:06:34 +03:00
Manos Pitsidianakis
d1499242b2
melib/error: add From<Infallible> impl
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-07-09 11:01:54 +03:00
Manos Pitsidianakis
386208664b
melib/error: detect DNS lookup std::io::Error
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-07-09 11:01:17 +03:00
Manos Pitsidianakis
100fa8b3d1
melib/utils: fix edge case in ShellExpandTrait
If there is no "/" prefix after stripping the argument prefix, the
result was reverted.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-07-09 09:37:55 +03:00
Manos Pitsidianakis
39e903b1d3
melib/utils: fix issues with ShellExpandTrait
ShellExpandTrait was not expanding paths properly: tilde was expanded
even if it wasn't the first byte in the sequence. Since $HOME tends to
be an absolute path, the entire value of the path accumulator up till
that point was overwritten, meaning a /path/to/~/some/file would get
expanded to ${HOME}/some/file.

ShellExpandTrait was also not completing paths properly, especially
between the generic impl and the linux specialized one. This commit adds
test to make sure their behavior is synced and changes the result type
to an enum to make the result more descriptive.

Concerns #431.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-07-07 22:38:47 +03:00
Manos Pitsidianakis
5110813e87
melib/maildir: refactor MaildirOp and watch()
Refactor to remove unwraps and add None checks with returning errors
where appropriate.

Hopefully addresses #426

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-29 14:58:07 +03:00
Manos Pitsidianakis
84d93d6555
melib/imap: add support for ID extension (opt-in)
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:11 +03:00
Manos Pitsidianakis
af6838c20c
melib: add metadata field to MailBackendCapabilities
Add field for arbitrary metadata as a serde_json::Value.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:11 +03:00
Manos Pitsidianakis
d40ee6928f
melib/imap: extract tests mod from protocol_parser
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:11 +03:00
Manos Pitsidianakis
7c47f70217
melib/sieve: extract test and parser modules to files
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:11 +03:00
Manos Pitsidianakis
ebc1fa3b8a
melib/sieve: move module to self dir
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:11 +03:00
Manos Pitsidianakis
e96e9789db
melib/imap: don't discard pre-auth capabilities
The library user can retrieve capabilities from a mail backend, and they
might want to see pre-auth capabilities as well.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:10 +03:00
Manos Pitsidianakis
e3c1656e05
melib/imap: fix LOGINDISABLED support
LOGINDISABLED disables the LOGIN command, not authenticating in general;
doh! 🤦🤦🤦🤦

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:10 +03:00
Manos Pitsidianakis
9fb5bc41b4
melib/imap: impl AUTH=ANONYMOUS (RFC4505)
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:09 +03:00
Manos Pitsidianakis
1cce8c1162
melib/imap: accept invalid "+" CRLF cont req
Some servers erroneously send a "+" CRLF sequence instead of "+" SP
CRLF.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:09 +03:00
Manos Pitsidianakis
a9e9d952d5
melib/imap: change termination_string arg to Option
Change ImapConnection::read_lines function argument termination_string
from &[u8] to Option<&[u8]>.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:09 +03:00
Manos Pitsidianakis
6e1fea8059
melib/jmap: show suggestions on Unauthorized error
Show suggestions for solving Unauthorized connection errors.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:08 +03:00
Manos Pitsidianakis
f9a3b33397
melib/imap/operations: return NotFound on empty FETCH
If UID FETCH returns an OK response but without untagged fetch
responses, it means the UID was not found. Return a NotFound error in
this case and a ProtocolError in other error cases.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:08 +03:00
Manos Pitsidianakis
8c880dc747
melib/error: add {Error,ErrorKind}::is_recoverable()
Add methods to guess whether the error is transient and can be recovered
from.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:08 +03:00
Manos Pitsidianakis
7200589a9e
melib/error: add ErrorKind::NotFound
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:08 +03:00
Manos Pitsidianakis
6da4e2eca6
Replace stringify! in Debug impls with type checked macro
Add identify! macro which expands to stringify! but also const type
checks the value to prevent typos/wrong values.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:07 +03:00
Manos Pitsidianakis
e107d613a0
melib/backends: add prelude module for import cleanup
Add a prelude module under melib::backends that exports all types needed
to interact with a mail backend. This reduces the number of imports in
every related file.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-28 11:15:05 +03:00
Andrei Zisu
c04b593bdf
Use BODY instead of RFC822
RFC3501 seems to prefer BODY attributes as the more modern equivalent
to RFC822. For example, this also allows us to use BODY.PEEK. Since the
fetch methods in melib are tightly coupled with the parser, we have to
add this here if we want to use BODY attributes during fetch.
2024-06-28 11:14:05 +03:00
Manos Pitsidianakis
0ffe7fa5b3
melib: add text/plain or text/html arg for text decoding
In the function that decodes attachments to text, the default was
Text::Plain. Now it's passed via an argument so that Text::Html can also
be used.
2024-06-28 11:14:05 +03:00
Andrei Zisu
b4579075a8
melib/imap: Allow XOAUTH2 string passed as string
For cases in which the user of melib already knows the token and auth
string and doesn't have to call an outside command.
2024-06-28 11:14:04 +03:00
Andrei Zisu
6f61176a99
Remove unecessary mut modifier
This also makes sense semantically since as_bytes shouldn't be
performing any mutations.
2024-06-28 11:14:01 +03:00
Manos Pitsidianakis
7e8d19afc7
melib/email.rs: add Envelope::sender_any
Similar to Envelope::recipient_any, this method searches if its argument
exists in From: or Author: headers.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-15 16:45:09 +03:00
Manos Pitsidianakis
d3a45b3442
melib/notmuch: make default shared lib name a const
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-15 16:45:09 +03:00
Manos Pitsidianakis
ff3fe07758
Fix new 1.79.0 clippy lints
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-15 16:45:09 +03:00
Damian Poddebniak
7856ea33f0 refactor: Transition more to imap-codec 2024-06-08 17:50:35 +03:00
Damian Poddebniak
a8956bafc8 chore: Update to imap-codec v2.0.0-alpha.1 2024-06-08 17:49:55 +03:00
Manos Pitsidianakis
f1332e82b6
Bump version to 0.8.6
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-08 11:55:13 +03:00
Manos Pitsidianakis
01bc62e0ad
melib/attachments: add new_plaintext method
Add new convenience method AttachmentBuilder::new_plaintext(Vec<u8>)

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-05 19:46:38 +03:00
Manos Pitsidianakis
8dd87c1ac5
melib/email: add ContentType::is_text_plain()
Simple helper method to check if content-type is text/plain

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-03 10:12:26 +03:00
Manos Pitsidianakis
6be25ac3df
melib/jmap: don't use client field for get/posts
HTTP Requests should go through the get_async()/post_async() methods of
JmapConnection, which traces requests if optional feature `jmap-trace`
is enabled.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-02 15:15:34 +03:00
Manos Pitsidianakis
33999fc6ab
melib/jmap: re-add Submission to USING
Submission capability is necessary for Identity retrievals.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-02 15:15:34 +03:00
Manos Pitsidianakis
45bfcf8707
melib/email/headers/standards.rs: minor refactors
Refactor the standards! macro to remove unnecessary repetitions, and
also add RFC2183 as source for the Content-Disposition header.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-02 12:17:56 +03:00
Manos Pitsidianakis
3bab5324c4
melib/email: Improve Debug impl for ContentType etc
Improve Debug impl for ContentType, Text, ContentTransferEncoding which
all include bytes in some of their variants. The derived Debug
implementation did not show them as readable ascii strings, so a custom
impl was necessary to make it readable.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-06-02 12:15:33 +03:00
Manos Pitsidianakis
2bfe608678
view.rs: hide self from "add contacts" options
Adding ourselves to our contacts doesn't make sense (in the generic
case) so remove them from the list that is shown when the user selects
the add contacts shortcut.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-30 15:44:19 +03:00
Manos Pitsidianakis
571bd98497
Add proper imap-shell in tools subcommand for debugging
Add imap-shell to tools subcommand.

To use, run

  $ meli tools imap-shell <account-name>

Where account name is what you have in your config file.

For convenience, typing an invalid name will list all the valid names:

  $ meli tools imap-shell "asdf"
  The configuration file does not contain the account `asdf`. It contains the following:
  user@example.com
  work
  personal account
  Try again with a valid account name.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 22:46:08 +03:00
Manos Pitsidianakis
7eed944abc
melib/jmap: fix screwed up rfc8620 module split
I first split the rfc8620.rs into two files with an octopus merge but
getting fixups autosquashed in rebase was impossible with this approach.
So I made the split manually and botched the state of the two splitted
halves.

This commit removes extraneous code and the unused rfc8620.rs file.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 13:59:03 +03:00
Manos Pitsidianakis
f2b59a7633
jmap: add RequestUrlTemplate type
Add type that preserves both text (String) and parsed Url value for a
Url template.

Also add a test to catch regressions.

Closes #403 (JMAP: message body fetching broken on v0.8.5)

Fixes: 51e3f163d4 ("melib/jmap: Use Url instead of String in deserializing")
Resolves: https://git.meli-email.org/meli/meli/issues/403
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:13 +03:00
Manos Pitsidianakis
f7838b1ddf
jmap/rfc8620.rs: split to methods.rs and objects.rs
Split rfc8620 to two separate files.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
a78f3f261d
jmap/rfc8620: move submodules to jmap/
Part of simplifying jmap module hierarchy.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
50ecade74a
jmap: merge rfc8620/tests.rs to tests.rs
In anticipation of next commit which will flatten the rfc8620 module
(move submodules to root).

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
77867aeed4
jmap: unwrap object module
jmap module hierarchy has been historically weird at places, because
some modules had been developed in separate bursts.

Flatten object module since it was not necessary.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
fc1122a2aa
jmap/mailbox.rs: rename to backend_mailbox.rs
To differentiate with the `Mailbox` object module.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
7ba7dc70c5
jmap: imports cleanup in all modules
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
dce3852fe5
jmap: add capabilities module
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-29 00:51:12 +03:00
Manos Pitsidianakis
c65635ef60
melib/connections.rs: Fix compilation for macos
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
2024-05-20 10:17:04 +03:00