blob: 889ef06e190d6cf23ce5808bb2d3e1ded694e041 (
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
|
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.oauth = true
w.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.user = u.User
u.User = nil
u.Scheme = "https"
w.endpoint = u.String()
w.account = msg.Config
return nil
}
|