diff --git a/config.json b/config.json index a686e1f..bb8526a 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "Name": "pa", "Interval": { - "Email": "10s..30s", + "Input": "10s..30s", "OK": "6h0m0s..6h0m0s", "Error": "6h0m0s..6h0m0s" }, @@ -34,14 +34,5 @@ "Username": "noeasyrunstrucking@gmail.com", "Password": "thumper123" } - }, - "Emailer": { - "From": "breellocaldev@gmail.com", - "SMTP": "", - "POP3": "", - "IMAP": "imap.gmail.com:993", - "Password": "gojfkkfrkmtxzyro", - "Limit": 0 - }, - "EmailerEnabled": false + } } \ No newline at end of file diff --git a/config/config.go b/config/config.go index a339b06..09c6c12 100644 --- a/config/config.go +++ b/config/config.go @@ -3,7 +3,6 @@ package config import ( "encoding/json" "io/ioutil" - "local/sandbox/contact/contact" "local/storage" "os" "sync" @@ -12,7 +11,7 @@ import ( type Config struct { Name string Interval struct { - Email Duration + Input Duration OK Duration Error Duration } @@ -40,8 +39,6 @@ type Config struct { Password string } } - Emailer contact.Emailer - EmailerEnabled bool lock sync.Mutex db storage.DB diff --git a/main.go b/main.go index ca6e30b..e6e16fa 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" "local/storage" "local/truckstop/broker" "local/truckstop/config" @@ -12,7 +11,6 @@ import ( "log" "regexp" "sort" - "strings" "sync" "time" ) @@ -23,17 +21,10 @@ func main() { lock := &sync.Mutex{} go func() { for { - time.Sleep(config.Get().Interval.Email.Get()) + time.Sleep(config.Get().Interval.Input.Get()) if err := config.Refresh(); err != nil { log.Println(err) } else { - if config.Get().EmailerEnabled { - lock.Lock() - if err := email(); err != nil { - log.Print(err) - } - lock.Unlock() - } if config.Get().Message.Matrix.ReceiveEnabled { lock.Lock() if err := matrixrecv(); err != nil { @@ -94,32 +85,6 @@ func setNewStates(states map[config.State]struct{}) { } } -func email() error { - log.Printf("checking email...") - ch, err := config.Get().Emailer.ReadIMAP() - if err != nil { - ch, err = config.Get().Emailer.ReadIMAP() - } - if err != nil { - return err - } - states := map[config.State]struct{}{} - for email := range ch { - if len(states) > 0 { - continue - } - if !strings.Contains(email.Header.Get("From"), config.Get().Client) { - continue - } - b, _ := ioutil.ReadAll(email.Body) - for _, state := range parseOutStates(b) { - states[state] = struct{}{} - } - } - setNewStates(states) - return nil -} - func parseOutStates(b []byte) []config.State { var states []config.State var state config.State diff --git a/todo.yaml b/todo.yaml index 0c4115e..96526a9 100644 --- a/todo.yaml +++ b/todo.yaml @@ -1,6 +1,4 @@ todo: -- send matrix msg on config change -- rm email - modify old items once no longer available - many users -> 1 ntg query - accept after date @@ -18,6 +16,8 @@ todo: - accept states via element for one system - set up copy for caleb, broc done: +- rm email +- send matrix msg on config change - setup pa on element - configurable email interval - jitter on intervals, including dedicated err span