about summary refs log tree commit diff stats
path: root/linux/parse-int.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-06-08 11:57:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-06-08 11:57:03 -0700
commit227d18f8a235701ea10b067ab4e1d3d8d2b579ed (patch)
tree128d9c5bdac594dd029c255fc2b159f1b4af46a6 /linux/parse-int.mu
parent9d2c64455a87edd4d241cbedd18963010b110a32 (diff)
downloadmu-227d18f8a235701ea10b067ab4e1d3d8d2b579ed.tar.gz
shell: first test for entire environment
This introduces some ergonomic issues. But we have to start somewhere.
Diffstat (limited to 'linux/parse-int.mu')
0 files changed, 0 insertions, 0 deletions
9cd271817e79fe634b1dd84'>88c379d ^
6271d45 ^







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62




                                     
                                               




                                                                          

                                                                             






























                                                                                      







                                                                      

                                                                             







                                                                        
package imap

import (
	"github.com/emersion/go-imap"

	"git.sr.ht/~sircmpwn/aerc/worker/types"
)

func (imapw *IMAPWorker) handleDeleteMessages(msg *types.DeleteMessages) {
	item := imap.FormatFlagsOp(imap.AddFlags, true)
	flags := []interface{}{imap.DeletedFlag}
	uids := toSeqSet(msg.Uids)
	if err := imapw.client.UidStore(uids, item, flags, nil); err != nil {
		imapw.worker.PostMessage(&types.Error{
			Message: types.RespondTo(msg),
			Error:   err,
		}, nil)
		return
	}
	var deleted []uint32
	ch := make(chan uint32)
	done := make(chan interface{})
	go func() {
		for seqNum := range ch {
			i := seqNum - 1
			deleted = append(deleted, imapw.seqMap[i])
			imapw.seqMap = append(imapw.seqMap[:i], imapw.seqMap[i+1:]...)
		}
		done <- nil
	}()
	if err := imapw.client.Expunge(ch); err != nil {
		imapw.worker.PostMessage(&types.Error{
			Message: types.RespondTo(msg),
			Error:   err,
		}, nil)
	} else {
		<-done
		imapw.worker.PostMessage(&types.MessagesDeleted{
			Message: types.RespondTo(msg),
			Uids:    deleted,
		}, nil)
		imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
	}
}

func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) {
	item := imap.FormatFlagsOp(imap.AddFlags, true)
	flags := []interface{}{imap.SeenFlag}
	if !msg.Read {
		item = imap.FormatFlagsOp(imap.RemoveFlags, true)
		flags = []interface{}{imap.SeenFlag}
	}
	uids := toSeqSet(msg.Uids)
	if err := imapw.client.UidStore(uids, item, flags, nil); err != nil {
		imapw.worker.PostMessage(&types.Error{
			Message: types.RespondTo(msg),
			Error:   err,
		}, nil)
		return
	}
	imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
}