remove email scrape
This commit is contained in:
37
main.go
37
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
|
||||
|
||||
Reference in New Issue
Block a user