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 }