aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-05-20 19:20:20 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-20 19:28:04 -0400
commit2dc436555d8bfa6f2409173d87cd0fec2b2385cf (patch)
tree73e589fc1ff64fa5f4362a9500a739703ea6a27c
parentcc90cd21610e7c78bc2cd9b04840fa1266617e6f (diff)
Load IMAP worker for imap+insecure
-rw-r--r--widgets/account.go6
-rw-r--r--worker/imap/worker.go3
-rw-r--r--worker/worker.go8
3 files changed, 13 insertions, 4 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 4ccb43d..bd47f46 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -37,7 +37,8 @@ func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
worker, err := worker.NewWorker(acct.Source, logger)
if err != nil {
- host.SetStatus(fmt.Sprintf("%s: %s", acct.Name, err))
+ host.SetStatus(fmt.Sprintf("%s: %s", acct.Name, err)).
+ Color(tcell.ColorDefault, tcell.ColorRed)
return &AccountView{
acct: acct,
grid: grid,
@@ -74,6 +75,9 @@ func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
}
func (acct *AccountView) Tick() bool {
+ if acct.worker == nil {
+ return false
+ }
select {
case msg := <-acct.worker.Messages:
msg = acct.worker.ProcessMessage(msg)
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index ade539a..125fba8 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -71,10 +71,9 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
w.config.addr = u.Host
if !strings.ContainsRune(w.config.addr, ':') {
- w.config.addr += ":" + u.Scheme
+ w.config.addr += ":" + w.config.scheme
}
- w.config.scheme = u.Scheme
w.config.user = u.User
case *types.Connect:
var (
diff --git a/worker/worker.go b/worker/worker.go
index 2a43083..7db7be5 100644
--- a/worker/worker.go
+++ b/worker/worker.go
@@ -7,6 +7,7 @@ import (
"fmt"
"log"
"net/url"
+ "strings"
)
// Guesses the appropriate worker type based on the given source string
@@ -16,7 +17,12 @@ func NewWorker(source string, logger *log.Logger) (*types.Worker, error) {
return nil, err
}
worker := types.NewWorker(logger)
- switch u.Scheme {
+ scheme := u.Scheme
+ if strings.ContainsRune(scheme, '+') {
+ scheme = scheme[:strings.IndexRune(scheme, '+')]
+ fmt.Println(scheme)
+ }
+ switch scheme {
case "imap":
fallthrough
case "imaps":