aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* composer: reopen the email file when editor is closedRobin Jarry2023-08-021-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some text editors save changes in a temp file before moving it over to the destination instead of rewriting the original file in place. This protects against all sorts of corruption, like writing partial files in disk-full scenarios for example. When this is the case, aerc's open file descriptor points to a different file, one that was never written to by the editor. For text editors that *do* overwrite the file (i.e. the same filesystem inode id), depending on timing, kernel version, operating system, filesystem options, caching, etc. Reading from aerc's file descriptor after the text editor has modified the same file on disk may not return the updated data. This behaviour can be easily observed with the following C program: #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { int fd; ssize_t n; char buf[BUFSIZ]; unlink("test.txt"); fd = open("test.txt", O_CREAT|O_RDWR, 0644); write(fd, "Bonjour\n", strlen("Bonjour\n")); fsync(fd); lseek(fd, 0, SEEK_SET); n = read(fd, buf, sizeof(buf)); buf[n] = '\0'; printf("before: %s\n", buf); system("vim test.txt"); lseek(fd, 0, SEEK_SET); n = read(fd, buf, sizeof(buf)); buf[n] = '\0'; printf("after: %s\n", buf); return 0; } Most of the time, before and after texts will be identical even if you modified the test.txt file contents in the editor. The only reliable way to ensure to read the latest contents from the disk is to close and reopen the file after the text editor has exited. Do exactly that in termClosed before anything else. Fixes: 801caf812377 ("compose: factorize body read in a method") Fixes: https://todo.sr.ht/~rjarry/aerc/184 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ronald Evers <ronald@ch10.nl>
* compose: fix panic when adding empty header with uppercase lettersRobin Jarry2023-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running `:header Hello` causes a panic: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa09328] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/widgets.(*Composer).AddEditor git.sr.ht/~rjarry/aerc/widgets/compose.go:1302 git.sr.ht/~rjarry/aerc/commands/compose.Header.Execute git.sr.ht/~rjarry/aerc/commands/compose/header.go:83 git.sr.ht/~rjarry/aerc/commands.(*Commands).ExecuteCommand git.sr.ht/~rjarry/aerc/commands/commands.go:133 main.execCommand git.sr.ht/~rjarry/aerc/main.go:71 This is because addEditor() converts the header name to lowercase before updating the c.editors map. After this, c.editors[header] (with `header` containing uppercase letters) returns nil causes a nil pointer access. This is a side effect of splitting AddEditor into public and private functions. focusEditor also converts the argument to lowercase. Fix and simplify this. Only call focusEditor with whatever the user provided. Fixes: 11e5390fa0ac ("compose: implement embedded headers in editor") Reported-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* compose: allow removing headersRobin Jarry2023-07-314-20/+47
| | | | | | | | Allow removing headers from the compose window when edit-headers=false (the default) with :header -d <name>. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* split: ensure messagestore is availableMoritz Poldrack2023-07-281-0/+4
| | | | | | | | | | Checking that a messagestore is connected, prevents crashes when aerc has disconnected or :v?split is called without delay inside the aerc-startup hook. Reported-by: Ryan Roden-Corrent <ryan@rcorre.net> Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: replace redundant default bindAnton Mosich2023-07-281-1/+1
| | | | | | | | <C-PgDn> was defined twice in the [compose::editor] context. I changed one of the definitions to a proper <C-PgUp> one. Signed-off-by: Anton Mosich <anton@mosich.at> Acked-by: Robin Jarry <robin@jarry.cc>
* textinput: fix deleteWord with an only whitespaceOskar Sharipov2023-07-282-1/+73
| | | | | | | | | | | Fix a panic in the textinput.deleteWord when text is a whitespace symbol. Add tests for textinput. Fixes: https://todo.sr.ht/~rjarry/aerc/183 Signed-off-by: Oskar Sharipov <oskargit@riseup.net> Acked-by: Robin Jarry <robin@jarry.cc>
* contrib: actually fix irc patchset hook when author is not registeredRobin Jarry2023-07-282-4/+6
| | | | | | | | When the author is not registered in sr.ht, the schema object is different. Fixes: 3a73ffb40ed1 ("contrib: fix irc patchset hook when author is not registered") Signed-off-by: Robin Jarry <robin@jarry.cc>
* compose: only add signature if missingRobin Jarry2023-07-171-1/+21
| | | | | | | | | Allow putting signatures in the templates. Do not add a duplicate signature during :recall and :recover. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: allow changing edit-headers on the flyRobin Jarry2023-07-1712-54/+180
| | | | | | | | | Add -e|-E flags to all compose commands to allow switching between edit-headers = true/false without restarting aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: implement embedded headers in editorKoni Marti2023-07-177-56/+262
| | | | | | | | | Implement embedded header mode in the composer widget. To activate it, use set [compose].edit-headers=true in aerc.conf. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* compose: always use cr-lf line endingsRobin Jarry2023-07-171-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | .eml files are universally formatted with DOS line-endings, per RFC5322. Make sure to replace line endings with CRLF before sending the message. Always present CRLF files to the text editor. If the editor forces LF line endings, convert them back to CRLF. Text editors (vim and nvim at least) detect the .eml extension and force dos line endings. Emacs seems not to care and will use whatever line endings are present in the file. Kakoune seems to force unix line endings and does not care about the contents of the file. Notes: * add explicit calls to Truncate() to ensure any trailing content is stripped from the file when overwriting with shorter content. * NewCRLFReader cannot be reused since we need buffered and unbuffered versions of it (for GetBody and {Set,append}Contents, respectively). Link: https://datatracker.ietf.org/doc/html/rfc5322 Link: https://github.com/vim/vim/blob/v8.2.3583/runtime/ftplugin/mail.vim#L29-L35 Link: https://github.com/neovim/neovim/blob/v0.6.0/runtime/ftplugin/mail.vim#L29-L35 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: improve error handlingRobin Jarry2023-07-172-25/+35
| | | | | | | | | On error, return to the caller instead of logging a warning and trying to continue. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: factorize body read in a methodRobin Jarry2023-07-171-33/+25
| | | | | | | | | | | | | | In preparation for allowing headers in the text editor, put code related to reading the email body in a method and use it where needed. Never close the email temp file, always keep it opened in read-write mode. This will be also required to update embedded header values when running :edit after modifying email headers from the compose::review screen. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: only allow setting content at creationRobin Jarry2023-07-179-74/+45
| | | | | | | | | | | | | Add a parameter for the initial value of the body to be inserted *before* the signature when composing a message. Make AppendContents and SetContents private methods to ensure there is no other way to change the composer contents from the outside after creation. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* send: return error when recipients list is emptyRobin Jarry2023-07-171-0/+3
| | | | | | | | Avoid sending messages with no recipients. Fixes: https://todo.sr.ht/~rjarry/aerc/182 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* imap: fix header cache key collisionsRobin Jarry2023-07-161-13/+17
| | | | | | | | | | | | | | | | | | | | | | Sometimes, aerc lists completely random messages when opening a mailbox. It only happens when cache-headers=true. According to RFC 3501: > The combination of mailbox name, UIDVALIDITY, and UID must refer to > a single immutable message on that server forever. It turns out that several mailboxes may have the same UIDVALIDITY value and may contain messages that have the same UID. When that happens, aerc assumes that the headers for these messages are already cached and returns them whereas they are for messages from another mailbox. Add the mailbox name into the header cache key to avoid these confusing collisions. Fixes: 7aa71d334b27 ("imap: add option to cache headers") Link: https://datatracker.ietf.org/doc/html/rfc3501#section-2.3.1.1 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* styles: add style for folded threadsKoni Marti2023-07-162-0/+8
| | | | | | | | | Add a style for folded threads. Use msglist_thread_folded in the stylesheet like "msglist_thread_folded.dim = true" Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* templates: add ThreadCount and ThreadFoldedKoni Marti2023-07-169-14/+67
| | | | | | | | | | | | | | Add the number of threads and a flag to indicated folded threads to the template data. Use {{.ThreadCount}} and {{.ThreadFolded}} in template expression for the message list. column-subject = {{.ThreadPrefix}}{{if .ThreadFolded}}[{{.ThreadCount}}] {{end}}{{.Subject}} Update default configuration accordingly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* commands: add :fold and :unfold for thread foldingKoni Marti2023-07-162-0/+51
| | | | | | | | | | Add the :fold and :unfold commands to perform thread folding. They only work on the selected message. Add vim-like bindings. Fixes: https://todo.sr.ht/~rjarry/aerc/148 Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* store: implement thread foldingKoni Marti2023-07-162-1/+39
| | | | | | | | Implement thread folding on the message store level. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* msglist: simplified threads renderingKoni Marti2023-07-161-55/+39
| | | | | | | | | | | Simplifies the rendering of threads by removing a thread specific loop and just add the relevent threading information. Since the uids are ordered based on the thread structure already by the threadbuilder, it is not necessary to loop over the threads slice. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* threadbuilder: store uid/thread associationKoni Marti2023-07-163-41/+49
| | | | | | | | | | | | | | Store the association between uids and threads in a map instead of just having the threads in a slice. This simplifies the lookup of a thread when we have an uid and we can avoid computationally expensive tree walks. The threadbuilder will rebuild the uids from the given thread structure. Hence there is no need now to keep a threads slice around. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* commands: fix panic in helper structKoni Marti2023-07-151-1/+5
| | | | | | | | | | | | Fix a panic in the helper struct than can occur when a delayed archiving operation (from :send -a) occurs and the user is already in a different window that does not implement the ProvideMessages interface. Use the *AccountView as a fallback when the type cast fails. Fixes: https://todo.sr.ht/~rjarry/aerc/181 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* wizard: properly initialize configurationRobin Jarry2023-07-154-59/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wizard constructs an AccountConfig object by hand without initializing default values. This causes a crash when replying to an email (rr) just after completing the account creation: ~/.config/aerc/aerc.conf not found, installing the system default~/.config/aerc/binds.conf not found, installing the system defaultpanic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x5d1550] ... regexp.(*Regexp).doExecute(0x7fc1089aa108?, {0x0?, 0x0?}, {0x0?, 0x0?, 0xc000fe5408?}, {0xc000698120?, 0x10?}, 0xad3a40?, 0x2, ...) regexp/exec.go:527 +0x90 regexp.(*Regexp).FindString(0x44e372?, {0xc000698120, 0x27}) regexp/regexp.go:852 +0x6c git.sr.ht/~rjarry/aerc/commands/msg.trimLocalizedRe({0xc000698120, 0x27}, 0xc00003e420?) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:332 +0x36 git.sr.ht/~rjarry/aerc/commands/msg.reply.Execute({}, 0xc0002ba180, {0xc0002f8800?, 0x2, 0x2}) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:157 +0x765 ... Extract the account parsing and initialization into a function. Reuse that function in both accounts.conf parsing and the wizard. Fixes: 40cc540357d9 ("reply: allow to override localized Re regexp in configuration") Reported-by: Mechiel Lukkien <mechiel@ueber.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Andrew Yu <andrew@andrewyu.org>
* jmap: fix crash when opening multiple instancesRobin Jarry2023-07-152-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following error when opening another aerc instance with the same jmap account: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x9a1ffd] git.sr.ht/~rjarry/aerc/worker/jmap/cache.(*JMAPCache).get(0x99d08e?, {0xbc3c1a?, 0xc00003a160?}) git.sr.ht/~rjarry/aerc/worker/jmap/cache/cache.go:47 +0x1d git.sr.ht/~rjarry/aerc/worker/jmap/cache.(*JMAPCache).GetSession(0xc00052a030?) git.sr.ht/~rjarry/aerc/worker/jmap/cache/session.go:8 +0x29 git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).handleConnect(0xc00055e180, 0x0?) git.sr.ht/~rjarry/aerc/worker/jmap/connect.go:29 +0xd3 git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).handleMessage(0xc000311500?, {0xcc8b00?, 0xc0001fcff0?}) git.sr.ht/~rjarry/aerc/worker/jmap/worker.go:114 +0x9f git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).Run(0xc00055e180) git.sr.ht/~rjarry/aerc/worker/jmap/worker.go:177 +0x10c git.sr.ht/~rjarry/aerc/widgets.NewAccountView.func3() git.sr.ht/~rjarry/aerc/widgets/account.go:110 +0x65 created by git.sr.ht/~rjarry/aerc/widgets.NewAccountView git.sr.ht/~rjarry/aerc/widgets/account.go:103 +0x518 Do not return an error if the leveldb cannot be opened, log a message and fallback on the in-memory cache. Fixes: be0bfc1ae28b ("worker: add jmap support") Reported-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* foldermap: make folder-map syntax more expressiveKoni Marti2023-07-143-11/+142
| | | | | | | | | | | | | | | | | | | | | | | | | Improve the folder mapping syntax so that prefixes can be removed completely. The following line in the folder-map file * = INBOX/* will strip the INBOX/ prefix from all subfolders of INBOX, e.g. map "INBOX/Project1" to "Project1". To prevent a key collision with multiple "*" keys (the folder mapping is stored as a map internally), a group of "*" will be condensed to one "*", e.g. ** = INBOX/* has the same meaning as above. Also, adjust name translation for folder creation and add tests. Fixes: https://todo.sr.ht/~rjarry/aerc/176 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* config: recognize empty no-attachment-warningNojus Gudinavičius2023-07-141-0/+3
| | | | | | | | | | Documentation above no-attachment-warning states "Leave empty to disable this feature". However, when left empty, it would always warn before sending an email without any attachments. Change to no warning if left empty. Signed-off-by: Nojus Gudinavičius <nojus.gudinavicius@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* contrib: fix irc patchset hook when author is not registeredRobin Jarry2023-07-142-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid running into KeyError because the webhook payload does not have a submitter canonicalName field. { "data": { "webhook": { "uuid": "69635b8e-8af5-4292-866b-1e45f75c132a", "event": "PATCHSET_RECEIVED", "date": "2023-07-11T13:55:17.248351983Z", "patchset": { "id": 42569, "subject": "Commands: add :echo command", "version": 1, "prefix": "aerc", "list": { "name": "aerc-devel", "owner": { "canonicalName": "~rjarry" } }, "submitter": {} } } } } Add username and email as fallback values. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* viewer: avoid high cpu usage when selecting part with no filterRobin Jarry2023-07-101-5/+10
| | | | | | | | | | | | | | | | When selecting a message part that has no filter configured, aerc uses very high CPU. This is due to a recursive UI invalidation. PartViewer.Draw() calls newNoFilterConfigured which calls ui.Grid.AddChild which in turn calls ui.Invalidate() which causes the whole UI to be redrawn. Call newNoFilterConfigured only once when creating a new part viewer (only when there is no filter command). Reported-by: Willow Barraco <contact@willowbarraco.fr> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Willow Barraco <contact@willowbarraco.fr>
* doc: fix hooks title level in aerc-config(5)Robin Jarry2023-07-101-1/+1
| | | | | | | It should be a top level item. Fixes: f10b184eb346 ("hooks: add aerc-startup hook") Signed-off-by: Robin Jarry <robin@jarry.cc>
* binds: add more default bindsRobin Jarry2023-07-081-2/+33
| | | | | | | | | | | These are from my own config. They may be helpful to others. Remove "q" to quit from the message list without confirmation. Add <ctrl-c> and <ctrl-q> to quit from any context. Suggested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* open: add option -d to automatically delete temporary filesVitaly Ovchinnikov2023-07-073-3/+28
| | | | | | | | | | | | | | | By default `:open` leaves its temporary files in the temp directory. The patch adds an option `-d` that defers the deletion of the temporary file when the opener is started. This works well with "sync" openers that don't exit until the user is done with the preview, but may not work with "async" openers that pass the file to their parent process and exit. That's why the automatic deletion needs to be intentionally enabled by using the option. Suggested-by: Robin Jarry <robin@jarry.cc> Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* lib: invert logic of mimeDB lookupMoritz Poldrack2023-07-061-4/+2
| | | | | | | This just looked weird. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* aerc.conf: update filters help to match aerc-config(5)Sebastian LaVine2023-07-061-0/+3
| | | | | | | | | /usr/libexec was not listed in the default search $PATH. Add it to match the man page. Fixes: 04303172d4f9 ("filters: install them in $PREFIX/libexec/aerc/filters") Signed-off-by: Sebastian LaVine <mail@smlavine.com> Acked-by: Robin Jarry <robin@jarry.cc>
* contrib: add irc bot stuffRobin Jarry2023-07-0110-0/+251
| | | | | | | | | | | Add a small script to install a sourcehut webhook that triggers on patchset reception. Add a limnoria (supybot fork) plugin to receive the webhook requests and send IRC NOTICE messages on the proper channels. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* templates: process reversed names betterVitaly Ovchinnikov2023-06-293-3/+136
| | | | | | | | | | | | | | | | | | | Change the behavior of `names`, `firstnames` and `initials` functions in templates so they better process names formatted like this: "Last Name, First Name" Basically, if the name contains one (and only one) comma, its parts are flipped so the first name always goes first. This helps to do "Hello Name" in templates regardless of the name format in email address. Also if the template uses a full name it will make it "Hello FirstName LastName" instead of "Hello LastName, FirstName". Add tests to cover more complex names in the future. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* doc: mention :search in aerc(1)Robin Jarry2023-06-292-2/+11
| | | | | | | | | :search is mentioned in the help of :filter of aerc(1), but is not "documented" which might be confusing for new users. Add a shallow entry that points to aerc-search(1). Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Inwit <inwit@sindominio.net>
* account: remember folder/message when reconnectingKoni Marti2023-06-263-4/+6
| | | | | | | | | | Remember selected folder and message when reconnecting. This is mostly useful for the imap backend when logouts or reconnects happen a lot. Fixes: https://todo.sr.ht/~rjarry/aerc/159 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* parse-links: be more strict with url parsingRobin Jarry2023-06-252-19/+108
| | | | | | | Reuse the same logic than colorize.c to allow parsing markdown links. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* imap: only call UidSort with sort criteriaKoni Marti2023-06-251-2/+3
| | | | | | | | | | | | | Only call UidSort with some sort criteria. If we call it without, some imap severs report it as an error. For example, Fastmail imap with the sort config in aerc.conf commented out reports: "[Fastmail] unexpected error: Missing Sort criteria" and cannot display the messages. Fixes: https://lists.sr.ht/~rjarry/aerc-devel/%3C5955665f-4d1a-4295-86bd-d1a5eabd0d6d%40milic.suse.cz%3E Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* open: use the original attachment extension if possibleVitaly Ovchinnikov2023-06-252-3/+10
| | | | | | | | | | | | | When opening an attachment with :open command we make a temporary file and open it then. The file is named randomly, but the extension is derived from the attachment parameters. This patch checks if the attachment has a file name assigned and takes the extension from there. Otherwise it rolls back to the original mime-based extension generation. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* jmap: avoid displaying archive folder when use-labels=trueRobin Jarry2023-06-253-6/+22
| | | | | | | | | | When archiving a message, the counts of archive folder are changed. When use-labels=true, the archive folder is hidden and should remain so. Do not send updates to the UI. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* doc: folder-map in aerc-accountsKoni Marti2023-06-222-0/+34
| | | | | | | | Document folder-map option in aerc-accounts. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* maildir: add folder-mapKoni Marti2023-06-224-20/+56
| | | | | | | | | | | | | Add the folder-map functionality to the maildir backend. If the folder-map config option is specified, the folder-map worker middleware is used. Unroll the worker.PostMessageInfoError function for a streamlined WorkerInteractor interface. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* imap: add folder-mapKoni Marti2023-06-224-5/+27
| | | | | | | | | Add the folder-map functionality to the imap backend. If the folder-map config option is specified, the folder-map worker middleware is used. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* lib: parse query-map and folder-map filesKoni Marti2023-06-223-17/+90
| | | | | | | | Combine the query-map and folder-map parsing functionality. Add tests. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* worker: implement folder-map middlewareKoni Marti2023-06-221-0/+152
| | | | | | | | | | Implement a folder-map middleware that will translate the folder names between the ui and the backend according to a provided key-value map. Fixes: https://todo.sr.ht/~rjarry/aerc/175 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* worker: add WorkerInteractor interfaceKoni Marti2023-06-229-41/+35
| | | | | | | | | | | | Add a WorkerInteractor interface. Avoid exposing any public fields in the types.Worker. This will set the stage to implement a middleware pattern for the workers, i.e. to map folder names between the ui and the backend. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* textinput: fix stemming with multi-byte charsKoni Marti2023-06-221-1/+1
| | | | | | | | | Fix a panic in the textinput when using multi-byte chars in the completions. Fixes: https://todo.sr.ht/~rjarry/aerc/180 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* worker: add jmap supportRobin Jarry2023-06-2133-10/+2507
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for JMAP backends. This is on par with IMAP features with some additions specific to JMAP: * tagging * sending emails This makes use of git.sr.ht/~rockorager/go-jmap for the low level interaction with the JMAP server. The transport is JSON over HTTPS. For now, only oauthbearer with token is supported. If this proves useful, we may need to file for an official three-legged oauth support at JMAP providers. I have tested most features and this seems to be reliable. There are some quirks with the use-labels option. Especially when moving and deleting messages from the "All mail" virtual folder (see aerc-jmap(5)). Overall, the user experience is nice and there are a lot less background updates issues than with IMAP (damn IDLE mode hanging after restoring from sleep). I know that not everyone has access to a JMAP provider. For those interested, there are at least these two commercial offerings: https://www.fastmail.com/ https://www.topicbox.com/ And, if you host your own mail, you can use a JMAP capable server: https://stalw.art/jmap/ https://www.cyrusimap.org/imap/download/installation/http/jmap.html Link: https://www.rfc-editor.org/rfc/rfc8620.html Link: https://www.rfc-editor.org/rfc/rfc8621.html Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>