aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/archive.go
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2023-01-03 12:13:14 +0100
committerRobin Jarry <robin@jarry.cc>2023-01-04 22:57:25 +0100
commit36fded03e762da97edde61559c8bf60d5749d6a2 (patch)
tree6a55c921e71390f550b56a8c222d17487e433983 /commands/msg/archive.go
parenta42042f494cc3a3e7a34bc13525c7a95cad3174f (diff)
downloadaerc-36fded03e762da97edde61559c8bf60d5749d6a2.tar.gz
send: add option to send&archive
Add `:send -a flat|month|year` to send, which archives the message being replied to. Extract most of archive logic into a separate function to make sure it behaves as manual archiving. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/msg/archive.go')
-rw-r--r--commands/msg/archive.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index 149d7a5f..aeb65738 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -39,29 +39,35 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("Usage: archive <flat|year|month>")
}
h := newHelper(aerc)
- acct, err := h.account()
+ msgs, err := h.messages()
if err != nil {
return err
}
- store, err := h.store()
+ err = archive(aerc, msgs, args[1])
+ return err
+}
+
+func archive(aerc *widgets.Aerc, msgs []*models.MessageInfo, archiveType string) error {
+ h := newHelper(aerc)
+ acct, err := h.account()
if err != nil {
return err
}
- msgs, err := h.messages()
+ store, err := h.store()
if err != nil {
return err
}
- archiveDir := acct.AccountConfig().Archive
var uids []uint32
for _, msg := range msgs {
uids = append(uids, msg.Uid)
}
+ archiveDir := acct.AccountConfig().Archive
marker := store.Marker()
marker.ClearVisualMark()
next := findNextNonDeleted(uids, store)
var uidMap map[string][]uint32
- switch args[1] {
+ switch archiveType {
case ARCHIVE_MONTH:
uidMap = groupBy(msgs, func(msg *models.MessageInfo) string {
dir := path.Join(archiveDir,