summary refs log tree commit diff stats
path: root/worker/imap/fetch.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker/imap/fetch.go')
-rw-r--r--worker/imap/fetch.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index 8052e13..feae462 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -30,6 +30,18 @@ func (imapw *IMAPWorker) handleFetchMessageBodies(
 	imapw.handleFetchMessages(msg, &msg.Uids, items)
 }
 
+func (imapw *IMAPWorker) handleFetchMessageBodyPart(
+	msg *types.FetchMessageBodyPart) {
+
+	imapw.worker.Logger.Printf("Fetching message part")
+	section := &imap.BodySectionName{}
+	section.Path = []int{msg.Part}
+	items := []imap.FetchItem{section.FetchItem()}
+	uids := imap.SeqSet{}
+	uids.AddNum(msg.Uid)
+	imapw.handleFetchMessages(msg, &uids, items)
+}
+
 func (imapw *IMAPWorker) handleFetchMessages(
 	msg types.WorkerMessage, uids *imap.SeqSet, items []imap.FetchItem) {
 
@@ -43,12 +55,8 @@ func (imapw *IMAPWorker) handleFetchMessages(
 			section := &imap.BodySectionName{}
 			for _msg := range messages {
 				imapw.seqMap[_msg.SeqNum-1] = _msg.Uid
-				if reader := _msg.GetBody(section); reader != nil {
-					imapw.worker.PostMessage(&types.MessageBody{
-						Reader: reader,
-						Uid:    _msg.Uid,
-					}, nil)
-				} else {
+				switch msg.(type) {
+				case *types.FetchMessageHeaders:
 					imapw.worker.PostMessage(&types.MessageInfo{
 						BodyStructure: _msg.BodyStructure,
 						Envelope:      _msg.Envelope,
@@ -56,6 +64,18 @@ func (imapw *IMAPWorker) handleFetchMessages(
 						InternalDate:  _msg.InternalDate,
 						Uid:           _msg.Uid,
 					}, nil)
+				case *types.FetchMessageBodies:
+					reader := _msg.GetBody(section)
+					imapw.worker.PostMessage(&types.MessageBody{
+						Reader: reader,
+						Uid:    _msg.Uid,
+					}, nil)
+				case *types.FetchMessageBodyPart:
+					reader := _msg.GetBody(section)
+					imapw.worker.PostMessage(&types.MessageBodyPart{
+						Reader: reader,
+						Uid:    _msg.Uid,
+					}, nil)
 				}
 			}
 			if err := <-done; err != nil {
e='Blame the previous revision' href='/akkartik/mu/blame/012transform.cc?h=main&id=18c57d32aec20e47ea7827460c0628ed218ef333'>^
37e4573b ^

dd2e01e4 ^
ac0e9db5 ^
dd2e01e4 ^
363be37f ^
37e4573b ^


91abd257 ^
363be37f ^
37e4573b ^


322ce34d ^
3ba63579 ^
5a481085 ^
3ba63579 ^


dd2e01e4 ^
57d01f21 ^
363be37f ^
3ba63579 ^

ac0e9db5 ^
05d17773 ^
ac0e9db5 ^
05d17773 ^
3ba63579 ^
ac0e9db5 ^
05d17773 ^
3ba63579 ^





9cc16d04 ^
7f73795c ^
0f125d5f ^

37e4573b ^
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
63
64
65
66
67
68
69
70
71
72
73