mirror of
https://github.com/Xevion/scla-unsubscribe.git
synced 2025-12-06 01:16:15 -06:00
Info logs on new unseen emails
This commit is contained in:
@@ -334,7 +334,7 @@ func GetDirectory(letter rune) ([]Entry, error) {
|
|||||||
return entries, nil
|
return entries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetFullEntryCached(id string) (*FullEntry, error) {
|
func GetFullEntryCached(id string) (*FullEntry, bool, error) {
|
||||||
key := fmt.Sprintf("entry:%s", id)
|
key := fmt.Sprintf("entry:%s", id)
|
||||||
|
|
||||||
// Check if cached
|
// Check if cached
|
||||||
@@ -365,13 +365,13 @@ func GetFullEntryCached(id string) (*FullEntry, error) {
|
|||||||
|
|
||||||
// If cached, return it
|
// If cached, return it
|
||||||
if cached {
|
if cached {
|
||||||
return &entry, nil
|
return &entry, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not cached, get it
|
// If not cached, get it
|
||||||
entryPtr, err := GetFullEntry(id)
|
entryPtr, err := GetFullEntry(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache it
|
// Cache it
|
||||||
@@ -391,7 +391,7 @@ func GetFullEntryCached(id string) (*FullEntry, error) {
|
|||||||
log.Error().Err(err).Msg("Failed to save to cache")
|
log.Error().Err(err).Msg("Failed to save to cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
return entryPtr, nil
|
return entryPtr, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetFullEntry(id string) (*FullEntry, error) {
|
func GetFullEntry(id string) (*FullEntry, error) {
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -165,7 +166,7 @@ func main() {
|
|||||||
for entry := range incompleteEntries {
|
for entry := range incompleteEntries {
|
||||||
log.Debug().Str("name", entry.Name).Msg("Processing Entry")
|
log.Debug().Str("name", entry.Name).Msg("Processing Entry")
|
||||||
|
|
||||||
fullEntry, err := GetFullEntryCached(entry.Id)
|
fullEntry, cached, err := GetFullEntryCached(entry.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Failed to get full entry")
|
log.Fatal().Err(err).Msg("Failed to get full entry")
|
||||||
}
|
}
|
||||||
@@ -174,6 +175,10 @@ func main() {
|
|||||||
log.Warn().Str("name", fullEntry.Name).Msg("Entry has no email")
|
log.Warn().Str("name", fullEntry.Name).Msg("Entry has no email")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !cached {
|
||||||
|
log.Info().Str("name", fullEntry.Name).Str("email", fullEntry.Email).Msg("New Email Found")
|
||||||
|
}
|
||||||
log.Debug().Str("name", fullEntry.Name).Str("email", fullEntry.Email).Msg("Entry Processed")
|
log.Debug().Str("name", fullEntry.Name).Str("email", fullEntry.Email).Msg("Entry Processed")
|
||||||
entries <- fullEntry.Email
|
entries <- fullEntry.Email
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user