aboutsummaryrefslogtreecommitdiff
path: root/internal/feed
diff options
context:
space:
mode:
Diffstat (limited to 'internal/feed')
-rw-r--r--internal/feed/feed.go45
-rw-r--r--internal/feed/parse.go7
2 files changed, 48 insertions, 4 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go
new file mode 100644
index 0000000..59c15f2
--- /dev/null
+++ b/internal/feed/feed.go
@@ -0,0 +1,45 @@
+package feed
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/mmcdole/gofeed"
+
+ "github.com/Necoro/feed2imap-go/internal/config"
+)
+
+type Feed struct {
+ Name string
+ Target []string
+ Url string
+ config.Options
+ feed gofeed.Feed
+}
+
+type Feeds map[string]*Feed
+
+func (f Feeds) String() string {
+ var b strings.Builder
+ app := func(a ...interface{}) {
+ _, _ = fmt.Fprint(&b, a...)
+ }
+ app("Feeds [")
+
+ first := true
+ for k, v := range f {
+ if !first {
+ app(", ")
+ }
+ app(`"`, k, `"`, ": ")
+ if v == nil {
+ app("<nil>")
+ } else {
+ _, _ = fmt.Fprintf(&b, "%+v", *v)
+ }
+ first = false
+ }
+ app("]")
+
+ return b.String()
+}
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index 53ceb00..a38be92 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -8,7 +8,6 @@ import (
"github.com/mmcdole/gofeed"
- "github.com/Necoro/feed2imap-go/internal/config"
"github.com/Necoro/feed2imap-go/internal/log"
)
@@ -16,7 +15,7 @@ func context() (ctxt.Context, ctxt.CancelFunc) {
return ctxt.WithTimeout(ctxt.Background(), 60*time.Second)
}
-func parseFeed(feed *config.Feed) error {
+func parseFeed(feed *Feed) error {
ctx, cancel := context()
defer cancel()
fp := gofeed.NewParser()
@@ -27,7 +26,7 @@ func parseFeed(feed *config.Feed) error {
return nil
}
-func handleFeed(feed *config.Feed, wg *sync.WaitGroup) {
+func handleFeed(feed *Feed, wg *sync.WaitGroup) {
defer wg.Done()
log.Printf("Fetching %s from %s", feed.Name, feed.Url)
@@ -36,7 +35,7 @@ func handleFeed(feed *config.Feed, wg *sync.WaitGroup) {
}
}
-func Parse(feeds config.Feeds) {
+func Parse(feeds Feeds) {
var wg sync.WaitGroup
wg.Add(len(feeds))
d>Svend Sorensen2-9/+17 Instead of editing the password file directly using Emacs, "pass edit" is run. This allows password-store's git change tracking to work. This adds a dependency on the with-editor Emacs package. 2017-04-13Bump version1.7.1Jason A. Donenfeld1-1/+1 2017-04-13init: match only the public keyJason A. Donenfeld1-1/+1 2017-03-28Use $GPG variableJason A. Donenfeld1-3/+3 2017-03-20Fix compatibility with GnuPG 2.2.19Andreas Stieger2-2/+2 GnuPG 2.2.19 added a warning when no command was given. * src/password-store.sh (reencrypt_path): Add --decrypt to --list-only * tests/t0300-reencryption.sh (gpg_keys_from_encrypted_file): same https://bugs.gnupg.org/gnupg/msg9873 http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=commit;h=810adfd47801fc01e45fb71af9f05c91f7890cdb https://bugzilla.suse.com/show_bug.cgi?id=1028867 2017-03-01tests: fix on OSX by not using the tr hackJason A. Donenfeld3-5/+2 2017-02-26Bump version1.7Jason A. Donenfeld1-1/+1 2017-02-26Modernize makefileJason A. Donenfeld2-31/+36 2017-02-25CopyrightJason A. Donenfeld1-1/+1 2017-02-25StyleJason A. Donenfeld1-2/+2 2017-02-25git: use inner-most directoryJason A. Donenfeld2-27/+48 2017-02-25clip: sleep may require argv[0] to be sleepJason A. Donenfeld1-1/+1 2017-02-25man: document system extensionsJason A. Donenfeld1-2/+3