aboutsummaryrefslogtreecommitdiffstats
path: root/worker
Commit message (Collapse)AuthorAgeFilesLines
* treewide: replace uint32 uids with opaque stringsRobin Jarry2024-08-2829-283/+224
| | | | | | | | | | | | | | | | | Add a new models.UID type (an alias to string). Replace all occurrences of uint32 being used as message UID or thread UID with models.UID. Update all workers to only expose models.UID values and deal with the conversion internally. Only IMAP needs to convert these to uint32. All other backends already use plain strings as message identifiers, in which case no conversion is even needed. The directory tree implementation needed to be heavily refactored in order to accommodate thread UID not being usable as a list index. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* imap: fix SeqMap.Pop runtime errorKoni Marti2024-08-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a runtime error in the SeqMap.Pop function causing a index-out-of-range panic: Version: 0.18.2.r22.gfff69046 (go1.22.6 amd64 linux 2024-08-10) Error: runtime error: index out of range [487] with length 487 goroutine 24430 [running]: runtime/debug.Stack() runtime/debug/stack.go:24 +0x5e git.sr.ht/~rjarry/aerc/lib/log.PanicHandler() git.sr.ht/~rjarry/aerc/lib/log/panic-logger.go:49 +0x66a panic({0x5dbf5a688020?, 0xc002ab0d80?}) runtime/panic.go:770 +0x132 git.sr.ht/~rjarry/aerc/worker/imap.(*SeqMap).Pop(0xc0003d4940, 0x1e8) git.sr.ht/~rjarry/aerc/worker/imap/seqmap.go:64 +0x17c git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleImapUpdate(0xc0003d4820, {0x5dbf5a6dbd00, 0xc002068708}) git.sr.ht/~rjarry/aerc/worker/imap/worker.go:296 +0x26c git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).drainUpdates.func1() git.sr.ht/~rjarry/aerc/worker/imap/flags.go:29 +0x10c created by git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).drainUpdates in goroutine 52 git.sr.ht/~rjarry/aerc/worker/imap/flags.go:21 +0x78 SeqMap.Pop uses two locks in the same function: first lock grabs the size of the slice, second lock removes the given index in the slice. Combine the two locks to prevent a change of the slice size before the index can be removed. Reported-by: Moritz Poldrack <moritz@poldrack.dev> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: fetch created messages and set recent flagTim Culverhouse2024-08-241-21/+49
| | | | | | | | | | When a push notification arrives, automatically fetch any newly created messages. Set the Recent flag on these messages to trigger a notification in the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: fix watcher pathThorben Günther2024-08-241-3/+14
| | | | | | | | | | | | | | The watcher path does not necessarily contain ".notmuch". From notmuch-config(1): Notmuch will store its database here, (in sub-directory named .notmuch if database.mail_root is unset). So we can simply check if the ".notmuch" folder exists and fallback to the default path if it does not. Signed-off-by: Thorben Günther <admin@xenrox.net> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: refactor thread fetchingTim Culverhouse2024-08-202-40/+23
| | | | | | | | | | | | | | | | | | Refactor JMAP thread fetching to occur in a single request. We use a result reference method call on Email/get to fetch the message info for each message in a thread. Previously, we checked the cache and only fetched information for messages we didn't already have. This results in two requests and is typically slower for most contexts. Also, in most cases if we are fetching an email we don't already have it's because we also need to fetch the entire thread. The only case this wouldn't happen is if we get a new email in a thread. We can optimize this by fetching message info for created messages in the push method at a later time. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: lazily fetch identitiesTim Culverhouse2024-08-202-19/+33
| | | | | | | | | | | | | Fetch Identities only when required: when we are sending an email. Refactor connect.go to check the state string of the Session on every request, and update the session as needed. Move the Session validity check to happen on any request, eg when our client returns an error we first update the Session object (via re-authenticating) and then retry the request. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir: set the forwarded flag when forwarding msgsinwit2024-08-203-7/+36
| | | | | | | | | | | The maildir backend was ignoring the passed/forwarded flag. Allow for this flag to be set and synced to the server (if the server admits it). Changelog-added: The maildir backend now honors the forwarded/passed flag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: set the "passed" tag when forwarding msgsinwit2024-08-203-8/+36
| | | | | | | | | | | | | | In notmuch, forwarded messages should be marked with the "passed" tag, which is subsequently synchronized with the corresponding maildir "P" flag. Ensure both flag and tag are applied to forwarded messages in the notmuch interface. Link: https://notmuchmail.org/special-tags/ Changelog-added: The notmuch backend now honors the forwarded flag, setting the "passed" tag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* forward: allow forwarded flag to be setinwit2024-08-201-0/+6
| | | | | | | | | | | | Usually, a MUA sets a flag for messages that have been forwarded, but this is currently not the case for aerc. Consider the forwarded flag and prepare aerc to set it everytime the :forward command is called and ends successfully. Changelog-added: The :forward command now sets the forwarded flag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir: only abort directory listing if there are 0 uidsBence Ferdinandy2024-08-201-1/+1
| | | | | | | | | | | | If there is an error in container.UIDs, we will abort handling the message list, resulting in showing the number of messages by the directory name, but having an empty message list showing. Only return with err, if UIDs actually returned 0 messages. References: https://todo.sr.ht/~rjarry/aerc/215 Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: fix emailKey function nameTristan Partin2024-08-201-4/+4
| | | | | | | This was just a simple typo. Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: reload all changed messages on DB changeJason Cox2024-08-202-23/+41
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7. As discussed in the aerc-devel thread for the reverted patch, the performance improvement comes with an issue: changes to message tags are no longer immediately reflected in the UI. This issue occurs whether the tags are modified from within aerc or externally with the notmuch CLI. The message list also flickers any time tag changes are made. Further, commit c36ed72e4a59 ("notmuch: speed up lastmod query") dramatically reduces the number of messages which are re-indexed when the database changes, likely eliminating the need for the reverted performance improvement anyway. Fixes: c56649fe5291 ("notmuch: don't reload all message on change") Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/53729 Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/54028 Reported-by: Robin Dapp <rdapp@modk.org> Reported-by: Ryan Winograd <ryan@thewinograds.com> Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* search,filter: add flag to use custom extensionsKoni Marti2024-08-041-0/+1
| | | | | | | | | | | | | | | | | | Add an extension flag to the search/filter command which will provide different completion strategies for the search terms and instruct the backend to use custom extensions (such as X-GM-EXT-1) if available. The following examples are based on the Gmail extension (note that this should be enabled in your accounts.conf with 'use-gmail-ext=true'): :filter -e filename:pdf from:bob :filter -e has:attachment newer_than:2d :search -e is:read is:starred :search -e list:~rjarry/aerc-devel@lists.sr.ht Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: expose extension in capabilitiesKoni Marti2024-08-041-0/+2
| | | | | | | | Expose the supported extensions in the capabilities. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: extend SEARCH with X-GM-RAW for full Gmail search syntaxKoni Marti2024-08-045-10/+193
| | | | | | | | | | | | | Extend the IMAP SEARCH command with the X-GM-RAW attribute for full Gmail search syntax. It is based on the Gmail extension (X-GM-EXT-1). The search/filter command will be interpreted in the same manner as in the Gmail web interface. Link: https://support.google.com/mail/answer/7190?hl=en Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: allow copying to current folderRobin Jarry2024-08-032-7/+12
| | | | | | | | | Add a new copy-to-replied setting in accounts.conf to copy sent replies to the same folder than their replied message. Requested-by: Tristan Partin <tristan@partin.io> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
* jmap: fetch entire threadsTristan Partin2024-08-034-36/+141
| | | | | | | | | | Fetch an email's entire thread in the JMAP backend. Changelog-added: Fetch entire threads in the JMAP backend. Signed-off-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: only send Done event if deletion succeedsHugo Osvaldo Barrera2024-08-031-1/+1
| | | | | | | | | | | | | | A Done event was sent from the worker to the UI unconditionally, so even if the deletion operation failed, the UI showed a "N messages deleted" confirmation. When no messages are deleted, don't send the done event. Given that the same function already sends an error in case of any failures, this error is what remains visible in the status bar. Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: remove redundant queryHugo Osvaldo Barrera2024-08-031-9/+8
| | | | | | | | | | | | | | This function first queried the notmuch database for a single filename (arbitrarily chosen), and then queried the database for all filenames of the same message. Drop one unnecessary query; only query all names, and then use the first one as an arbitrarily chosen one. Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl> Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: speed up lastmod query.Robin Dapp2024-08-031-1/+1
| | | | | | | | | | | | | | When changing the tag/label of a message we refresh all messages that were modified since the start of the transaction. To that end we add "lastmod before..now" to the current query without any conjunction. That would make us re-index basically all messages. This patch wraps the existing query in parentheses and ANDs it with "lastmod" instead which greatly speeds up the process. Signed-off-by: Robin Dapp <rdapp@modk.org> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: improve logging for watcherHugo Osvaldo Barrera2024-08-031-1/+2
| | | | | | | | | | | | | When an error occurs initialising a watcher, the error shown is completely unclear (e.g.: "no such file or directory"). Clarify the error so that its source is clear and log the path that was used. Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl> Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: don't reload all message on changeHugo Osvaldo Barrera2024-08-032-41/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | When a notmuch query result was shown and any message changes (e.g.: was marked as read, deleted, flagged, etc) the entire result set was reloaded from disk. This included querying the notmuch for paths for each file individually and then reading headers from each file one by one. If the current view was a query-map with 4000 results, then marking a single message as read resulted in 4000 files being read from disk. When a change is detected in the database, instead of sending an individual MessageInfo event for each message in the result set, send a single DirectoryContents event. The UI code will remove from view any messages that no longer exist, add new ones and request from the worker any data that may be required (this data will be lazy-fetched). This results in a dramatic performance improvement when reading messages from a query-map result. Previously reading a single message would result in about 2 minutes of CPU at 150% (on a i7-13700K). With this patch, the same operation uses less than 5% CPU for less than 2 seconds. Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: do not keep invalid sessions in cacheRobin Jarry2024-07-028-58/+59
| | | | | | | | | | | If a session is found in the cache, check that it works by issuing a GetIdentities request. If that request fails, invalidate the cache and go through the authentication. Ensure that the session is valid and explicitly fail if it is not. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* imap: report errors from serverRobin Jarry2024-07-011-21/+31
| | | | | | | | | | | | Avoid eternal spinner on the message list when the imap server advertises some message UIDs but fails to provide their headers when aerc asks from them. When an error occurs, or if some UIDs are not returned, make sure to report the errors to the message list UI. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
* jmap: revert fetch threads supportRobin Jarry2024-06-295-227/+32
| | | | | | | | | | | | | | This reverts commits: 9e93d9efdb88 ("jmap: fix go static check failure") 0465509eedad ("jmap: skip Email/get call if no emails to get") 9f97c698e3dd ("jmap: fetch entire threads") Issues have been reported about disappearing sent messages. Reported-by: Tristan Partin <tristan@partin.io> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tristan Partin <tristan@partin.io>
* threadbuilder: allow threading by subjectRobin Jarry2024-06-251-1/+1
| | | | | | | | | | | | If no match were found in the References and In-Reply-To headers, allow threading by looking at subjects. This behaviour is disabled by default. Add a setting to enable it. Changelog-added: Allow fallback to threading by subject with `[ui].threading-by-subject`. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Matěj Cepl <mcepl@cepl.eu>
* threadbuilder: show siblings even when no parent foundKoni Marti2024-06-251-0/+3
| | | | | | | | | | | | | | | Show all threading associations even when not all nodes are present. Indicate if a thread is incomplete, i.e. misses a direct parent node. Use the `msglist_thread_orphan.fg=red` styleobject in your stylesheet to indicate whether a messsage has a missing parent. Also use a different thread prefix ("┬─" instead of "├─") not to confuse them with regular threads that have a visible parent. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Matěj Cepl <mcepl@cepl.eu>
* query: allow forcing overwrite of existing folderBence Ferdinandy2024-06-232-1/+2
| | | | | | | | | | | | | | Currently, when using :query the user is forced to create a new folder for every query, since aerc doesn't allow overwriting an existing folder. Actually, "overwriting" an existing folder with a query is a non-destructive operation in the sense, that the underlying maildir is not touched, the only thing lost is the state in aerc. The current behaviour doesn't allow for a simple `:query -n query ` type of binding. Allow overwriting an existing folder with the -f flag. Changelog-added: Allow using existing directory name with `:query -f`. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: fix message list order directionRobin Jarry2024-06-051-1/+1
| | | | | | | | | | | | | Since the update to go-jmap 0.5.0, the IsAscending property is now taken into account even if it is false. The initial JMAP implementation wrongfully assumed the behaviour and inverted the sort -r logic. Fix that so that messages are ordered as expected. Link: https://git.sr.ht/~rockorager/go-jmap/commit/1db959676c10398a8 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* jmap: skip Email/get call if no emails to getTristan Partin2024-06-041-0/+4
| | | | | | | | No need to send a JMAP request if there are no object to fetch. Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* jmap: fix go static check failureTristan Partin2024-05-291-1/+1
| | | | | | | | The missing variable was being set but unused. Fixes: 9f97c698e3dd ("jmap: fetch entire threads") Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: fix error messageTristan Partin2024-05-291-1/+1
| | | | | | | | A v1 got committed when a v2 existed. Fixes: f9113810cc6c ("jmap: invalidate cache if mailbox state is not consistent") Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: fetch entire threadsTristan Partin2024-05-285-32/+223
| | | | | | | JMAP was missing good thread support, especially when compared to Gmail. This will fetch entire threads when possible. Signed-off-by: Tristan Partin <tristan@partin.io>
* jmap: invalidate cache if mailbox state is not consistentTristan Partin2024-05-282-11/+57
| | | | | | | | | We weren't checking if the cached state was the same as the remote state before reading it. This led to aerc not knowing about new mailboxes on the remote. Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: fix panic in connectKoni Marti2024-05-091-2/+3
| | | | | | | | | | | | | Fix a nil pointer dereference panic in connect when trying to obtain the folder delimiter. There is a List call to the imap server that in some instances can return a nil *imap.MailboxInfo that is not checked before it is dereferenced. Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CEDE672E5-3F6F-402D-B1A4-5477183FC13C@ukr.net%3E Reported-by: Misha <ulianich_mihail@ukr.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Reviewed-by: Tim Culverhouse <tim@tim.culverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: add imaps+insecure modeMoritz Poldrack2024-05-011-0/+3
| | | | | | | | | | | | | | When connecting through environments bypassing hostnames, like SSH tunnels, the certificate verification of the server will fail, making it impossible to connect, if plain IMAP has been disabled. Add handling for the insecure modifier to the imaps connection. Changelog-added: Add `imaps+insecure` to the available protocols, for connections that should ignore issues with certificate verification. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: fix disappearing messagesJulio B2024-04-141-1/+4
| | | | | | | | | | | The current implementation assumes that 'root[0].FirstChild' is nil, but this is not always the case. Instead of overwriting the FirstChild, detect and link the messages to the LastChild of root[0]. Fixes: 672b4edca7af ("notmuch: draw incomplete threads") Signed-off-by: Julio B <julio.bacel@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: use a custom prefix for dummy rootJulio B2024-04-132-0/+4
| | | | | | | | | | These messages are not really the root of the thread, and should not be displayed as such. Add a new special prefix to make them appear like the first child of a rootless thread. Signed-off-by: Julio B <julio.bacel@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: draw incomplete threadsJulio B2024-04-131-5/+11
| | | | | | | | | | Create a "pseudo thread" with the first message as root. This is a temporary solution, until we have a more generic implementation of dummy messages that works for all backends. Signed-off-by: Julio B <julio.bacel@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: add strategies for multi-file messagesJason Cox2024-04-025-93/+447
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A single notmuch message can represent multiple files. As a result, file-based operations like move, copy, and delete can be ambiguous. Add a new account config option, multi-file-strategy, to tell aerc how to handle these ambiguous cases. Also add options to relevant commands to set the multi-file strategy on a per-invocation basis. If no multi-file strategy is set, refuse to take file-based actions on multi-file messages. This default behavior is mostly the same as aerc's previous behavior, but a bit stricter in some cases which previously tried to be smart about multi-file operations (e.g., move and delete). Applying multi-file strategies to cross-account copy and move operations is not implemented. These operations will proceed as they have in the past -- aerc will copy/move a single file. However, for cross-account move operations, aerc will refuse to delete multiple files to prevent data loss as not all of the files are added to the destination account. See the changes to aerc-notmuch(5) for details on the currently supported multi-file strategies. Changelog-added: Tell aerc how to handle file-based operations on multi-file notmuch messages with the account config option `multi-file-strategy` and the `-m` flag to `:archive`, `:copy`, `:delete`, and `:move`. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Maarten Aertsen <maarten@nlnetlabs.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: simplify moving a messageJason Cox2024-04-021-10/+1
| | | | | | | | | Delete the existing file from the database after indexing the new one to avoid the need to remember and re-apply tags. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Maarten Aertsen <maarten@nlnetlabs.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: ignore duplicate msg ID error on deleteJason Cox2024-04-021-1/+1
| | | | | | | | | | | | | | | | | | According to the comments in notmuch.h, removing a file returns NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID when the "filename was removed but the message persists in the database with at least one other filename." Based on the fact that the db.DeleteMessage() function is used in a context that explicitly recognizes the possibility of multiple files and only attempts to delete one of them, I'm fairly certain that the existing behavior of ignoring all errors *except* the deplicate message ID error is the result of a typo. (It also doesn't make sense to ignore other errors, such as NOTMUCH_STATUS_XAPIAN_EXCEPTION.) Cc: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Maarten Aertsen <maarten@nlnetlabs.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* search: fix crash during message searchjp392024-04-021-5/+3
| | | | | | | | | | Initialize info in SearchMessage irregardless of the message parts flags otherwise it will crash when we attempt to read it in the next switch statement. Fixes: 8464b3738 ("search: use a common api for all workers") Signed-off-by: jp39 <jp39@gmx.com> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: drain updates channel when moving messagesKoni Marti2024-02-261-0/+3
| | | | | | | | | | | | | Drain the updates channel when moving messages to prevent a backend freeze. This also fixes a possible freeze for large-scale archive operations since the archive command uses the move operation. Reported-by: Moritz Poldrack <moritz@poldrack.dev> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jeremy Baxter <jtbx@disroot.org> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: add :query to create named notmuch dirsJason Cox2024-02-263-16/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current :cf command can be used to create folders for arbitrary notmuch queries. These folders use the query as their namee. In some cases, though, it's useful to give a more human-readable name. Create a new :query command to allow doing so. The :query command accepts an optional -n flag to specify a name. The remaining arguments are interpreted verbatim as a notmuch query. If no name is specified, the query itself is used as the name. For example, to create a new folder with the full thread of the current message, named by its subject, run the following command: :query -n "{{.SubjectBase}}" thread:"{mid:{{.MessageId}}}" :query could have been implemented as an additional flag to :cf. Giving a name to the created folder would make the smantics of :cf strange, though. For example, to create a named query folder, one would use :cf -n <name> <query>. This syntax feels odd; the name of the folder seems like it ought to be the positional argument of the change folder command. Alternatively, the usage could be :cf -q <query> <name>, but this feels wrong as well: the query, which is provided as a positional parameter when no name is specified, becomes a flag parameter when a name is specified. What's more, both of these potential usages add a notmuch-specific flag to an otherwise general command. Creating a new command feels cleaner. Perhaps the current query functionality of the :cf command could eventually be deprecated to remove the duplicate functionality and keep :cf limited to changing to existing folders. Changelog-added: Create notmuch named queries with the `:query` command. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: drain updates channel when deleting messagesKoni Marti2024-02-261-0/+40
| | | | | | | | | | | | | Drain the buffered updates channel when deleting messages to prevent a backend freeze. Unilateral update messages from the IMAP server can fill up the buffered channel if not handled during a large operation (more than ~50 messages). Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCZCPBTWI3PIW.T8MWNCBG7FGL%40disroot.org%3E Changelog-fixed: Prevent a freeze for large-scale deletions with IMAP. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jeremy Baxter <jtbx@disroot.org> Acked-by: Robin Jarry <robin@jarry.cc>
* log: move package to libRobin Jarry2024-02-1424-24/+24
| | | | | | | This has nothing to do at the root of the source tree. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* jmap: set explicit sender and recipientsKarel Balej2024-02-122-11/+14
| | | | | | | | | | | | | | | JMAP is able to automatically determine sender and recipients based on the message headers after it is submitted for sending. However this means that it is not possible to send a message with the From header not matching the account with this approach (or to send the message to recipients not listed in the headers). Luckily, JMAP allows setting the envelope containing the envelope sender and recipients manually. Modify the code to do so. Also bump go-jmap to include a fix needed for this to work. Signed-off-by: Karel Balej <balejk@matfyz.cz> Acked-by: Robin Jarry <robin@jarry.cc>
* filter: allow workers to combine filter termsKoni Marti2024-02-115-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the backend workers to combine the filter terms. Currently, the consecutive filters are joined in the message store with a space (" "). This works well for most backends, but makes the filter combination for notmuch confusing. Example: Issuing two consecutive filter commands in notmuch :filter not tag:list :filter tag:list would create the following filter query 'not tag:list tag:list' This is not what users would expect; they expect: '(not tag:list) and (tag:list)' Note that the notmuch backend works correctly for the given query, but produced a query that does not match the user's expectation. This patch fixes this. The combination of filter terms in other backends remains the same. Reported-by: Ángel Castañeda <angel@acsq.me> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: fix connection when host only has ipv6 addressRobin Jarry2024-02-041-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Some IMAP servers report both IPv4 and IPv6 addresses from their DNS name: $ host imap.gmail.com imap.gmail.com has address 108.177.15.109 imap.gmail.com has address 108.177.15.108 imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6c imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6d ResolveTCPAddr actually returns the first *IPv4* address by default, unless the address string is an explicit IPv6 address. Directly use net.Dial which has a fast fallback mechanism. It first tries to connect with an IPv6 address (if any) and if that fails, it will retry with an IPv4 address (if any) before failing completely. Link: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/ipsock.go;l=81 Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCYVLU3AOA00I.26I5IMAF3T4CK%40dow.land%3E Link: https://pkg.go.dev/net#Dial Reported-by: Jonathan Dowland <jon@dow.land> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>