284 Commits

Author SHA1 Message Date
Robin Jarry
0211c9bf23 reload: fix crash when reloading via IPC
When reloading the configuration with :reload, global variables in the
config package are reset to their startup values and then, the config is
parsed from disk. While the parsing is done, these variables are
temporarily in an inconsistent and possibly invalid state.

When commands are executed interactively from aerc, they are handled by
the main goroutine which also deals with UI rendering. No UI render will
be done while :reload is in progress.

However, the IPC socket handler runs in an independent goroutine. This
has the unfortunate side effect to let the UI goroutine to run while
config parsing is in progress and causes crashes:

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6bb142]

goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
	lib/log/panic-logger.go:51 +0x6cf
panic({0xc1d960?, 0x134a6e0?})
	/usr/lib/go/src/runtime/panic.go:783 +0x132
git.sr.ht/~rjarry/aerc/config.(*StyleConf).getStyle(0xc00038b908?, 0x4206b7?)
	config/style.go:386 +0x42
git.sr.ht/~rjarry/aerc/config.StyleSet.Get({0x0, 0x0, 0x0, {0x0, 0x0, 0x0}}, 0x421a65?, 0x0)
	config/style.go:408 +0x8b
git.sr.ht/~rjarry/aerc/config.(*UIConfig).GetStyle(...)
	config/ui.go:379
git.sr.ht/~rjarry/aerc/lib/ui.(*TabStrip).Draw(0xc000314700, 0xc000192230)
	lib/ui/tab.go:378 +0x15b
git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc000186fc0, 0xc0002c25f0)
	lib/ui/grid.go:126 +0x28e
git.sr.ht/~rjarry/aerc/app.(*Aerc).Draw(0x14b9f00, 0xc0002c25f0)
	app/aerc.go:192 +0x1fe
git.sr.ht/~rjarry/aerc/lib/ui.Render()
	lib/ui/ui.go:155 +0x16b
main.main()
	main.go:310 +0x997

Make the reload operation safe by changing how config objects are
exposed and updated. Change all objects to be atomic pointers. Expose
public functions to access their value atomically. Only update their
value after a complete and successful config parse. This way the UI
thread will always have access to a valid configuration.

NB: The account configuration is not included in this change since it
cannot be reloaded.

Fixes: https://todo.sr.ht/~rjarry/aerc/319
Reported-by: Anachron <gith@cron.world>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2025-09-08 12:19:51 +02:00
Moritz Poldrack
4d57c0157c unsubscribe: validate DKIM signatures before parsing unsubscribe links
According to RFC 8058, a List-Unsubscribe header must have a valid DKIM
signature. This is currently not checked for.

Implement a DKIM check before acting upon a subscribe link.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-08-04 12:48:13 +02:00
Moritz Poldrack
b1dca58421 unsubscribe: autoselect method if only one is available
If there is only one option to unsubscribe, select that method
automatically.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-08-04 12:48:10 +02:00
Moritz Poldrack
20443b89fe unsubscribe: properly send unsubscribe requests
According to RFC 8058, links in the List-Unsubscribe headers should have
a POST request sent to them. This is not possible in the current setup,
as links are only opened in a browser.

Change the default behaviour to match the RFC and keep an "Open in
Browser" option for non-compliant senders.

Link: https://datatracker.ietf.org/doc/html/rfc8058
Changelog-fixed: `:unsubscribe` now follows RFC 8058.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-08-04 12:47:53 +02:00
Moritz Poldrack
fc5b6896ff chore: switch to using stdlib helper functions
Go has evolved significantly over the years and has introduced some
handy helper functions that make the code easier to read.

Use helper functions like slices.Contains, map.Copy, and
strings.CutPrefix, when appropriate.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-08-04 12:47:05 +02:00
Moritz Poldrack
4c294387d2 mark: make recipient switch target all recipients
Contrary to popular belief, not all recipients of a mail are listed in
it's To: header. They may also be included in the Cc: or Bcc: headers.
Include them in the list when filtering.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-06-20 09:36:52 +02:00
Jörg Thalheim
d9a1acf27a pipe: add support for piping messages in compose review mode
Allow piping composed messages that are about to be sent in the compose
review mode. This enables users to process or inspect messages before
sending them.

Update documentation to reflect this new capability.

Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-06-20 09:02:01 +02:00
Jörg Thalheim
ca9be2ba9a pipe: refactor to move out doExec/doTerm functions
Move doExec and doTerm functions to package level. Both functions now
accept parameters for command, reader, name, and callback. doTerm
additionally accepts a silent flag.

This refactoring is a preparation to add COMPOSE_REVIEW to the supported
contexts.

Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-06-20 09:02:01 +02:00
inwit
7b841edb90 forward: allow cross-account forwarding
When forwarding an email using edit-headers=true, using :switch-account
alone is not enough to properly switch the account since you have to
change the From header manually. Add the -x [account] option to :forward
in order to switch the account before opening the composer, to remove
this friction when we already know we want to forward with a different
account.

Changelog-added: Forward with a different account than the current
 one with `:forward -x <account>`.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-06-20 09:02:01 +02:00
Simon Martin
de2006bbd3 config: allow controlling whether :delete is allowed from any folder
It's currently possible to delete mails (*not* move to Trash) from any
folder. What a delete action does depends on the mail client, and it is
often synonymous to "Move to trash", and aerc's behaviour can surprise
users (who will find out too late, when their mail is gone forever...).

This patch adds a configuration setting to control whether deletes are
allowed from any folder, or are restricted to the Trash and Junk
folders.

Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-06-11 10:12:16 +02:00
Moritz Poldrack
1fe8ed687c unmark: remove unsupported -v and -V flags from suggestions
The -v and -V flags are unsupported/nonsensical for the :unmark command,
but are still suggested in completions. Remove them.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Tested-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-05-12 13:24:05 +02:00
Moritz Poldrack
6baffcdae5 mark: add filter-based marking
Expand the :mark command with the ability to combine it with filters to
automatically mark all messages matching a filter. The filters can be
combined with -t and -T to narrow down the selected messages:

 :mark Delivered # mark all messages with "Delivered" in the Subject
 :mark -s amazon # mark all messages from "amazon"
 :unmark invoice # unmark all messages with "invoice" in the subject

Changelog-added: Support for marking multiple messages based on
 filters.
Changelog-deprecated: Support for go 1.22.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Tested-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-05-12 13:22:03 +02:00
Thorben Günther
f6d93737b0 reply: Check custom header for From address
In some cases no RFC822 header will contain the correct alias address.
One such example is a mailing list where the recipient address is only
an alias to the configured "from" address.
For instance Postfix offers the "X-Original-To" header [1].

[1]: https://www.postfix.org/postconf.5.html

Signed-off-by: Thorben Günther <admin@xenrox.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-05-05 13:49:07 +02:00
Simon Martin
cb95b819b7 msg: fix issue with reply-to-self introduced by 063c19b6
Commit 063c19b6 fixes an issue with reply-all when reply-to-self is set
to try, but unfortunately introduces a new one, reported by Drew on IRC:
it will systematically Cc the replier if they reply to an email they
sent to themselves.

The problem with that fix is that it removes the from from the deduper
loo late, and should have instead not put it there in the first place if
reply-to-self is true; this is exactly what this patch does.

Fixes: 063c19b6 ("honor reply-to-self when replying to all")
Fixes: https://todo.sr.ht/~rjarry/aerc/311
Reported-by: Drew Devault <sir@cmpwn.com>
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-05-05 10:53:28 +02:00
Robin Jarry
6c83f10135 commands: allow positional arguments starting with "-"
Since commit 1393344097 ("mod: update go-opt"), running :search or
:filter crashes with an obscure error:

  panic: *account.SearchFilter.EndDate: unsupported field type: struct

  goroutine 1 [running]:
  git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
         git.sr.ht/~rjarry/aerc/lib/log/panic-logger.go:51
  panic({0x104ce89c0?, 0x14000032f00?})
         runtime/panic.go:785
  git.sr.ht/~rjarry/go-opt/v2.(*optSpec).parseField.func1(...)
         git.sr.ht/~rjarry/go-opt/v2@v2.0.2/spec.go:149
  git.sr.ht/~rjarry/go-opt/v2.(*optSpec).parseField(...)
         git.sr.ht/~rjarry/go-opt/v2@v2.0.2/spec.go:186
  git.sr.ht/~rjarry/go-opt/v2.NewCmdSpec(...)
         git.sr.ht/~rjarry/go-opt/v2@v2.0.2/spec.go:111
  git.sr.ht/~rjarry/go-opt/v2.ArgsToStruct(...)
         git.sr.ht/~rjarry/go-opt/v2@v2.0.2/opt.go:147
  git.sr.ht/~rjarry/aerc/commands.ExecuteCommand(...)
         git.sr.ht/~rjarry/aerc/commands/commands.go:215
  ...

That error was fixed in go-opt.

Also, any argument starting with "-" is parsed as a flag or option and
never considered as a positional argument unless it is preceded by "--".

Lots of commands in aerc actually have positional arguments that need to
start with "-", such as:

  :tag -label
  :select -1
  :prev-folder -100

For this, a new minus:"true" tag must be added to positional arguments
that may take values starting with "-".

Link: https://git.sr.ht/~rjarry/go-opt/commit/63f7bfa70ffe
Link: https://git.sr.ht/~rjarry/go-opt/commit/c5a75f147f24
Reported-by: Sebastien Binet <s@sbinet.org>
Reported-by: Vitaly Ovchinnikov <v@ovch.ru>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>
2025-03-31 16:35:54 +02:00
inwit
a6220d025a tag: allow to toggle tags
So far, the :tag command in the notmuch and jmap workers allows adding a
tag (by prefixing it with '+') and removing it (by prefixing it with
'-'). Add a new functionality to this command, allowing it to toggle a
tag by prefixing it with '!'.

Fixes: https://todo.sr.ht/~rjarry/aerc/292
Changelog-added: It is now possible to toggle notmuch and JMAP tags.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-03-30 22:10:58 +02:00
Simon Martin
063c19b619 imap: honor reply-to-self when replying to all
The reply-to-self configuration is not always properly honored when
replying to all, due to a bug in reply.Execute's dedupe logic.

It uses a map to keep track of the addresses it has already seen, and
exclude them from the lists subsequently passed to "dedupe".

Since we use "dedupe" to build the reply's From, our address is excluded
when building the To/Cc, even if reply-to-self is true. This patch fixes
this by making sure that our address is *not* part of the exclude list
before building the reply's To/Cc.

Basic logs showing the behaviour with and without this patch can be
found here:
  https://paste.sr.ht/~simartin/e502022d06f8a3d8f827179f28d89165545af67f

Signed-off-by: Simon Martin <simon@nasilyan.com>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-03-19 00:28:47 +01:00
Moritz Poldrack
1d6eb2dc58 smtp: add option to request DSN for successful deliveries
In some cases it can be desirable to receive a success notification for
a message from the server. This currently only works on SMTP.

Changelog-added: Add option to request full DSN for SMTP sent messages.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-03-09 00:40:38 +01:00
Robin Jarry
4c7a22c179 composer: add flag to go directly to review screen
Add a new -s flag to skip opening the text editor and go directly to the
review screen for all commands that open a new composer widget.

Implements: https://todo.sr.ht/~rjarry/aerc/296
Changelog-added: All commands that involve composing messages
 (`:compose`, `:reply`, `:recall`, `:unsubscribe` and `:forward`) now
 have a new `-s` flag to skip opening the text editor and go directly
 to the review screen. Previously, this flag was restricted to calendar
 invitations response commands (`:accept`, `:accept-tentative` and
 `:decline`).
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>
2025-01-23 22:11:39 +01:00
Robin Jarry
4e545d45fa treewide: fix English spelling
Use codespell to fix typos in code, comments and man pages.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: inwit <inwit@sindominio.net>
2025-01-21 13:39:01 +01:00
Radim Krčmář
ac2e370581 reply: add -f flag to always include From header addresses
A badly implemented mailing list sets itself as Reply-To, which means
that the original sender currently gets dropped.

Add -f flag that sends reply to both From and Reply-to sets of
addresses.  Sending to both is allowed in the mail RFCs, so this flag
can be safely used for all mail.

Changelog-added: Reply to addresses in `From` and `Reply-To` headers
 with `:reply -f`.
Signed-off-by: Radim Krčmář <radim@krcmar.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-01-07 19:19:41 +01:00
Radim Krčmář
05ffa1954f reply: refactor ReplyToSelf
Use dedupe instead of a custom loop.

Signed-off-by: Radim Krčmář <radim@krcmar.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-01-07 19:19:27 +01:00
Radim Krčmář
275d9fb41c reply: completely de-duplicate recipients
Addresses could have been added multiple times to our recipient lists if
they were present multiple times in the original recipient lists.

Make sure that each recipient is unique.

Changelog-fixed: There should no longer be any duplicates in recipient
 lists when replying.
Signed-off-by: Radim Krčmář <radim@krcmar.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-01-07 19:16:38 +01:00
Radim Krčmář
fa50c69dd2 reply: refactor de-duplicating addresses
Use a helper function instead of repeating a pattern.

Signed-off-by: Radim Krčmář <radim@krcmar.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-01-07 19:16:23 +01:00
Radim Krčmář
bcbcaf617f reply: de-duplicate sender address
Sender could already be in the Cc list; make sure it is not duplicated.

Adding the whole cc list to recSet twice is fine.

Fixes: 88d5de97d6 ("reply: handle the Sender header")
Signed-off-by: Radim Krčmář <radim@krcmar.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-01-07 19:15:27 +01:00
Robin Jarry
854a73e893 pipe: fix panic when backend fails to parse message
When the backend (usually IMAP) fails to parse some of the piped
messages, they may have a nil Envelope but a non-nil Error field.

When that occurs, do not try to access Envelope and log an error
instead.

Fixes: https://todo.sr.ht/~rjarry/aerc/287
Reported-by: Matěj Cepl <mcepl@cepl.eu>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com>
2024-12-21 17:14:17 +01:00
Robin Jarry
553fabbc2e jmap: handle copy-to and :send -t
The jmap:// outgoing backend always copies (actually, just tags) the
sent emails with the mailbox that has the "sent" role. Regardless of the
copy-to or :send -t <folder> argument. Only the copy-to-replied setting
is effective.

Change the CopyTo parameter of the StartSendingMessage backend operation
to hold a list of folder names.

In the JMAP worker, label the sent message with the list of folders,
eliminating duplicates (e.g. do not label with "sent" role twice).

Reported-by: Matěj Cepl <mcepl@cepl.eu>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Matěj Cepl <mcepl@cepl.eu>
2024-12-21 17:02:31 +01:00
Koni Marti
7f28ba10d5 forward: fix panic when using :eml
Fix a panic when forwarding a message that was opened with :eml.
:forward will try to the set the forwarded flag but there's no
associated message store available for that message (it's either loaded
from disk or an attachment).

Fixes: b94b4c00c9 ("forward: allow forwarded flag to be set")
Reported-by: inwit <inwit@sindominio.net>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-11-09 19:02:39 +01:00
Karel Balej
e319d3291f reply: consider the From address too when checking aliases
This sets the likely usually desired From address when replying to a
previously sent email and does not compose To the alias instead (unless
reply-to-self is enabled).

Changelog-fixed: Aliases are now taken into account correctly when
 replying to own messages such as from the Sent folder or via a
 mailing list.
Signed-off-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-10-24 22:13:51 +02:00
Robin Jarry
d0484b153a completion: add command option descriptions
Add `desc:""` struct field tags in all command arguments where it makes
sense.

The description values will be returned along with completion choices.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00
Robin Jarry
26033eaecf completion: add commands descriptions
Update the Command interface to include a Description() method.
Implement the method for all commands using short descriptions inspired
from the aerc(1) man page.

Return the description values along with command names so that they can
be displayed in completion choices.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00
Robin Jarry
7069217834 viewer: avoid crashes on opening invalid messages
When an error occurs during the opening of a message because its
contents cannot be parsed, the PartSwitcher object is left to nil and
the err field is set to the reported error.

This defers the error reporting after the viewer tab is displayed but it
is not handled in all sub functions which assume that switcher cannot be
nil.

 Error: runtime error: invalid memory address or nil pointer dereference

 git.sr.ht/~rjarry/aerc/app.(*PartSwitcher).Show(...)
     /build/aerc/src/aerc/app/partswitcher.go:77
 git.sr.ht/~rjarry/aerc/app.(*MessageViewer).Show(...)
     /build/aerc/src/aerc/app/msgviewer.go:409
 git.sr.ht/~rjarry/aerc/lib/ui.(*Tabs).selectPriv(...)
     /build/aerc/src/aerc/lib/ui/tab.go:181
 git.sr.ht/~rjarry/aerc/lib/ui.(*Tabs).Add(...)
     /build/aerc/src/aerc/lib/ui/tab.go:75
 git.sr.ht/~rjarry/aerc/app.(*Aerc).NewTab(...)
     /build/aerc/src/aerc/app/aerc.go:511
 git.sr.ht/~rjarry/aerc/app.NewTab(...)
     /build/aerc/src/aerc/app/app.go:61
 git.sr.ht/~rjarry/aerc/commands/account.ViewMessage.Execute.func1(...)
     /build/aerc/src/aerc/commands/account/view.go:71
 git.sr.ht/~rjarry/aerc/lib.NewMessageStoreView.func1(...)
     /build/aerc/src/aerc/lib/messageview.go:80
 git.sr.ht/~rjarry/aerc/lib.NewMessageStoreView(...)
     /build/aerc/src/aerc/lib/messageview.go:124
 git.sr.ht/~rjarry/aerc/commands/account.ViewMessage.Execute(...)
     /build/aerc/src/aerc/commands/account/view.go:52
 git.sr.ht/~rjarry/aerc/commands.ExecuteCommand(...)
     /build/aerc/src/aerc/commands/commands.go:205
 main.execCommand(...)

Remove that private err field and return an explicit error when the
message cannot be opened to enforce handling of the error by the caller.

When the msg argument is nil (only used in split viewer), return an
empty message viewer object and ensure that all code paths that read the
switcher or msg fields perform a nil check before accessing it.

Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C12c465e4-b733-4b15-b4b0-62f87429fdf7@gmail.com%3E
Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C2C55CF50-A636-46E5-9BA8-FE60A2303ECA@proton.me%3E
Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD51PEB6OMNDT.1KVSX0UCNL2MB@posteo.de%3E
Reported-by: Benjamin Braun <ben.braun@posteo.de>
Reported-by: Filip <filip.sh@proton.me>
Reported-by: Sarthak Bhan <sbstratos79@gmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2024-10-22 19:44:36 +02:00
inwit
29f95c68e2 invite: honor the -a flag for :send
When sending replies to invitations with :accept, :accept-tentative or
:decline, calling `:send -a` in the review screen does not archive the
original invitation, as it should. Solve this situation and allow for
directly archiving invitations after replying to them.

Changelog-fixed: Invitations now honor the -a flag for :send.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-10-21 23:25:44 +02:00
Johannes Thyssen Tishman
7c50ee0de6 reply: make {{.OriginalText}} available to custom templates
Currently {{.OriginalText}} is only available to the quote-reply
template when using `:reply -q`. Allow templates specified using the
`-T` flag to make use of it too.

Changelog-changed: Templates passed to the `:reply` command using the
 `-T` flag can now make use of `{{.OriginalText}}`.
Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-10-12 00:13:10 +02:00
inwit
09d283c9f7 calendar: skip editor when replying to invitations
Most of the time, accepting an invitation does not require editing the
automatically generated email before sending it. Allow the user to
optionally skip the editor entirely and go directly to the review screen
when dealing with invitations.

References: https://todo.sr.ht/~rjarry/aerc/247
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-03 09:49:54 -05:00
Robin Jarry
73dc39c6ee treewide: replace uint32 uids with opaque strings
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>
2024-08-28 12:06:01 +02:00
Vitaly Ovchinnikov
3ce5670fdc forward: better preserve attached file names
Use a dedicated filename function for getting a name of the attached
file instad of analyzing its mime type. Some attachments have file name
in `Content-Disposition` rather than `Content-Type`, the new method
handles both cases.

Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-08-24 15:49:17 +02:00
inwit
4f11457790 flag: manually toggle the forwarded tag
Allow the user to manually set, unset and toggle the forwarded tag.

Changelog-added: The :flag command now sets/unsets/toggle the
 forwarded tag.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-08-20 11:54:34 +02:00
inwit
b94b4c00c9 forward: allow forwarded flag to be set
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>
2024-08-20 11:54:34 +02:00
Koni Marti
a64563466d copy: add -d flag to decrypt before copying
Add -d flag to the copy command to decrypt a message before copying it.

Implements: https://todo.sr.ht/~rjarry/aerc/238
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Jens Grassel <jens@wegtam.com>
Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-08-20 11:54:34 +02:00
Koni Marti
658ddc8aba pipe: add -d flag to decrypt message
Add -d flag to the pipe command to decrypt a message before it is piped.

Implements: https://todo.sr.ht/~rjarry/aerc/238
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Jens Grassel <jens@wegtam.com>
Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-08-20 11:54:34 +02:00
Robin Jarry
954c812d84 reply: allow copying to current folder
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>
2024-08-03 20:19:37 +02:00
Bence Ferdinandy
88d5de97d6 reply: handle the Sender header
Sometimes emails will have a Sender: header, that is different from the
From: header. The only use of this in the wild I have seen to date is
when meeting invitation is forwarded by somebody. The From: header will
be the person organising the meeting, and the Sender: will be the person
forwarding. Naturally, when one replies (e.g. with on accept), it should
go to the meeting oragniser, but sometimes one would want to include the
Sender in such a reply.

When executing :reply determine the To: address in order of Reply-To:,
From:, Sender:. When executing :reply -a, include the Sender: in Cc:.

Implements: https://todo.sr.ht/~rjarry/aerc/259
Link: https://www.rfc-editor.org/rfc/rfc4021#section-2.1.3
Changelog-added: Replying to all will include the Sender in Cc.
Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-08-03 20:05:29 +02:00
Robin Jarry
9cd806fa6e cc,bcc,forward: add completion from address book
Allow using the address book for completion in the :cc, :bcc and
:forward commands.

Changelog-added: The address book is now used for `:cc`, `:bcc` and
 `:forward`.
Requested-by: Maximilian Bosch <maximilian@mbosch.me>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Tested-by: Maximilian Bosch <maximilian@mbosch.me>
2024-06-25 00:29:51 +02:00
Robin Jarry
20c63c6943 move: avoid crash when message list is not ready
Fix the following crash:

panic: runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
        runtime/panic.go:770 +0x132
git.sr.ht/~rjarry/aerc/lib.(*MessageStore).Selected(...)
        git.sr.ht/~rjarry/aerc/lib/msgstore.go:709
git.sr.ht/~rjarry/aerc/commands/msg.Move.CallBack()
        git.sr.ht/~rjarry/aerc/commands/msg/move.go:178 +0x78
git.sr.ht/~rjarry/aerc/commands/msg.Move.Execute.func1()
        git.sr.ht/~rjarry/aerc/commands/msg/move.go:75 +0x90
git.sr.ht/~rjarry/aerc/lib.(*MessageStore).Move.func1()
        git.sr.ht/~rjarry/aerc/lib/msgstore.go:645 +0x138

When a move operation finishes, the callback is invoked but there is no
guarantee that the target account has any message store ready (e.g. IMAP
may be disconnected).

Only access acct.Store() in the happy code path and even there, only use
store if is is not nil.

Fixes: 40c25caafd ("mv: allow to move messages across accounts")
Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD114PEHTFKRE.2R9XF4U2BBDD6@mailbox.org%3E
Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD118R1N4XZ1X.1ZFQPGG8DSCDA@schaeffer.tk%3E
Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD1B2PVIVGPOZ.1925R9LL60EAZ@disroot.org%3E
Reported-by: Alex Freudenberg <alexfxd@mailbox.org>
Reported-by: Evin Yulo <yujiri@disroot.org>
Reported-by: Maarten Aertsen <sagi+aerc-devel@rtsn.nl>
Reported-by: Yuri Schaeffer <yuri@schaeffer.tk>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Tristan Partin <tristan@partin.io>
2024-06-04 21:11:16 +02:00
Johannes Thyssen Tishman
9849601906 pipe: allow closing the terminal automatically
Add a new -s flag to :pipe. When specified, the terminal tab opened by
the :pipe command will be automatically closed after the process is
completed instead of prompting for a key press. While this doesn't
technically silence the command (the output is not suppressed), the
output is not shown to the user.

Changelog-added: Silently close the terminal tab after piping a
 message to a command with `:pipe -s <cmd>`.
Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-04-13 21:47:44 +02:00
Johannes Thyssen Tishman
3d529aa093 config: make popover dialogs configurable
Add the [ui].dialog-{position,width,height} options in aerc.conf to set
the position, width and height of popover dialogs such as the one from
:menu, :envelope or :attach -m relative to the main window.

Changelog-added: Add `[ui].dialog-{position,width,height}` to set
 the position, width and height of popover dialogs.
Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-04-02 22:22:33 +02:00
Jason Cox
1ce82f50d0 notmuch: add strategies for multi-file messages
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>
2024-04-02 22:22:28 +02:00
Robin Jarry
2453375721 commands: rename confusing constants
There is an overlap between ACCOUNT and MESSAGE. Rename ACCOUNT to
MESSAGE_LIST and use MESSAGE_LIST|MESSAGE_VIEWER instead of MESSAGE.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
2024-03-04 22:30:14 +01:00
Koni Marti
d56e949a33 commands: allow to forward from eml
Forward messages from the message viewer when they are opened with :eml (e.g.
rfc822 attachments). Those messages have no associated message store and
currently :forward would complain about that.

References: https://todo.sr.ht/~rjarry/aerc/227
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-02-14 23:20:46 +01:00