2021-01-29 12:29:23 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"git.sr.ht/~ewintr/gte/internal/task"
|
|
|
|
"git.sr.ht/~ewintr/gte/pkg/mstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-01-29 17:22:07 +01:00
|
|
|
config := &mstore.ImapConfiguration{
|
|
|
|
ImapUrl: os.Getenv("IMAP_URL"),
|
|
|
|
ImapUsername: os.Getenv("IMAP_USERNAME"),
|
|
|
|
ImapPassword: os.Getenv("IMAP_PASSWORD"),
|
2021-01-29 12:29:23 +01:00
|
|
|
}
|
|
|
|
if !config.Valid() {
|
2021-01-29 17:22:07 +01:00
|
|
|
log.Fatal("please set IMAP_USER, IMAP_PASSWORD, etc environment variables")
|
2021-01-29 12:29:23 +01:00
|
|
|
}
|
|
|
|
|
2021-01-29 17:22:07 +01:00
|
|
|
mailStore, err := mstore.ImapConnect(config)
|
2021-01-29 12:29:23 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer mailStore.Disconnect()
|
|
|
|
|
|
|
|
taskRepo := task.NewRepository(mailStore)
|
2021-01-29 17:22:07 +01:00
|
|
|
tasks, err := taskRepo.FindAll(task.FOLDER_INBOX)
|
2021-01-29 12:29:23 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
for _, t := range tasks {
|
2021-01-29 17:22:07 +01:00
|
|
|
if t.Dirty {
|
2021-01-29 12:29:23 +01:00
|
|
|
if err := taskRepo.Update(t); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|