aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch/message.go
Commit message (Collapse)AuthorAgeFilesLines
* treewide: replace uint32 uids with opaque stringsRobin Jarry2024-08-281-2/+2
| | | | | | | | | | | | | | | | | 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>
* notmuch: set the "passed" tag when forwarding msgsinwit2024-08-201-0/+5
| | | | | | | | | | | | | | 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>
* 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: add strategies for multi-file messagesJason Cox2024-04-021-60/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* log: move package to libRobin Jarry2024-02-141-1/+1
| | | | | | | 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>
* notmuch: centralize flag/tag mappingsJason Cox2024-01-261-21/+9
| | | | | | | | Mimic other backends that have centralized mappings. Doing so makes adding support for the draft flag simpler in a subsequent commit. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: add full path of file(s) as Filename(s)Bence Ferdinandy2023-12-311-0/+4
| | | | | | | | | | | | | For the maildir and notmuch backends, add the full path of the message as Filename to templates. In case of a notmuch message having multiple files associated with it, it returns a random path. Also add Filenames to templates, which is a list of all associated message paths. This is relevant for the notmuch backend, where a single messages is shown, if there are multiple copies of it. Changelog-added: Add filepath to messages in templates as .Filename(s) Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* worker: move shared code to libRobin Jarry2023-10-281-3/+4
| | | | | | | | | | | | | Avoid importing code from worker/lib into lib. It should only be the other way around. Move the message parsing code used by maildir, notmuch, mbox and the eml viewer into a lib/rfc822 package. Adapt imports accordingly. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* notmuch: refactor SetFlagTim Culverhouse2023-08-311-17/+10
| | | | | | | | | Refactor SetFlag to be more readable by handling the special case of SeenFlag in a cleaner way. If we invert the operation ('enable') instead of invert the oldState, we can use the same logic for any tag. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* messageinfo: report message sizesKoni Marti2023-04-261-1/+14
| | | | | | | Report sizes of the message across all backends. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* model: change flags array to bitmaskRobin Jarry2023-01-041-13/+7
| | | | | | | Using a list of integers is not optimal. Use a bit mask instead. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* notmuch: preserve tags when moving messagesinwit2022-12-021-2/+14
| | | | | | | | Keep the original tags when a message is moved from one maildir folder to another. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: add maildir supportJulian Pidancet2022-10-271-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | By associating the notmuch database with a maildir store, we can add the Copy/Move/Delete operations on messages to the notmuch backend. This change assumes that the notmuch database location is also the root of the maildir store. In a previous change, we added the ability to dynamically add and remove message files to the notmuch DB. This change uses this facility to synchronize the database with the filesystem operations on maildir files. While it's still possible to use the query-map file to create virtual folders from notmuch search queries, the sidebar is now loaded with the folders found in the maildir store. With notmuch, two identical but distinct message files can be indexed in the database with the same key. This change takes extra care of only deleting or removing message files from the maildir corresponding to the folder that is currently selected (if any). Implements: https://todo.sr.ht/~rjarry/aerc/88 Fixes: https://todo.sr.ht/~rjarry/aerc/73 Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* charset: handle unknown charsets more user-friendlyKoni Marti2022-09-251-3/+1
| | | | | | | | | Do not throw an error when the charset is unknown; the message entity can still be read, but log the error instead. Reported-by: falsifian Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: work nicely with wrapped errors (errorlint)Moritz Poldrack2022-08-041-1/+1
| | | | | | | | Error wrapping as introduced in Go 1.13 adds some additional logic to use for comparing errors and adding information to it. Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: apply new formatting rulesMoritz Poldrack2022-08-011-6/+6
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir,notmuch: avoid leaking open filesNguyễn Gia Phong2022-01-191-7/+2
| | | | | | | | | | Previously, Message.NewReader returned the wrapped buffered reader without a reference to the opened file, so the files descriptors were left unclosed after reading. Now, the file reader is returned directly and closed on the call site. Buffering is not needed here because it is an implementation detail of go-message. Fixes: https://todo.sr.ht/~rjarry/aerc/9
* format: reformat code with go 1.17Robin Jarry2021-12-111-1/+2
| | | | | | | | There was a change in how build tags are formatted. Use this as new reference. Link: https://go.dev/doc/go1.17#gofmt Signed-off-by: Robin Jarry <robin@jarry.cc>
* go.mod: change base git urlRobin Jarry2021-11-051-3/+3
| | | | | | | I'm not sure what are the implications but it seems required. Link: https://github.com/golang/go/issues/20883 Signed-off-by: Robin Jarry <robin@jarry.cc>
* notmuch: don't read the full file into memoryReto Brunner2021-02-081-9/+3
|
* notmuch: rename method to SetFlagReto Brunner2020-09-271-4/+4
|
* Add additional flagging functionalityARaspiK2020-07-081-46/+44
| | | | | | | | | | | | | | More mail flags can now be set, unset, and toggled, not just the read/seen flag. This functionality is implemented with a new `:flag` and `:unflag` command, which are extensions to the matching `:read` and `:unread` commands, adding support for different flags. In fact, the `read`/`unread` commands are now recognized aliases to `flag`/`unflag`. The new commands are also well documented in aerc(1). The change mostly extends the previous read/unread setting functionality by adding a selection for the flag to change.
* notmuch: undefined variable when setting reply flagSrivathsan Murali2020-05-261-1/+1
|
* Set AnsweredFlag on successful replySrivathsan Murali2020-05-251-0/+33
|
* Add labels to index format (%g)Reto Brunner2019-12-271-0/+4
| | | | Exposes the notmuch tags accordingly, stubs it for the maildir worker.
* notmuch: extract all notmuch db operations.Reto Brunner2019-09-161-85/+49
| | | | | | For some reason the current code frequently segfaults due to an invalid C memory address. This commit mediates that by never keeping an object alive longer than absolutely necessary.
* Notmuch: use adhoc write connection.Reto Brunner2019-08-261-12/+79
| | | | | | | | Notmuch only allows a single write connection, all other clients trying to modify the db block. Hence we should only open one when we actually need it. Apparently we also need to refresh the RO DB connection upon modification, else we get stale message tag results
* Add notmuch backendReto Brunner2019-08-081-0/+123
This commit introduces the notmuch backend. The backend is conditionally compiled in if the "notmuch" tag is provided. Most of the message types are implemented, with the notable exceptions of DeleteMessages as well as any copy / move / append type. Reason being, that those aren't normally applicable in a notmuch based workflow. Changes v2 --> v3, based on review comments * Use account config for configuration