blob: f423ce4becfb34e5bb72e09390dc10ba1308c815 (
plain)
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
|
package jmap
import (
"fmt"
"net/url"
"strings"
"git.sr.ht/~rjarry/aerc/worker/types"
)
func (w *JMAPWorker) handleConfigure(msg *types.Configure) error {
u, err := url.Parse(msg.Config.Source)
if err != nil {
return err
}
if strings.HasSuffix(u.Scheme, "+oauthbearer") {
w.config.oauth = true
w.config.query = u.Query()
} else {
if u.User == nil {
return fmt.Errorf("user:password not specified")
} else if u.User.Username() == "" {
return fmt.Errorf("username not specified")
} else if _, ok := u.User.Password(); !ok {
return fmt.Errorf("password not specified")
}
}
u.RawQuery = ""
u.Fragment = ""
w.config.user = u.User
u.User = nil
u.Scheme = "https"
w.config.endpoint = u.String()
w.config.account = msg.Config
switch strings.ToLower(msg.Config.Params["use-labels"]) {
case "1", "t", "true", "yes", "y", "on":
w.config.useLabels = true
}
w.config.allMailName = msg.Config.Params["all-mail-name"]
if w.config.allMailName == "" {
w.config.allMailName = "All mail"
}
return nil
}
|