aboutsummaryrefslogtreecommitdiff
path: root/internal/imap
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-10-17 17:04:06 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-10-18 18:36:04 +0200
commit5c29e49f9f422c8889ce2ed6b5b5a2914b55cace (patch)
tree20b2d8725fa0bc763d32b6f59d796143a453548e /internal/imap
parent44ff3d08a0e1f3b49e07795a9fdb0ad3af4c7540 (diff)
downloadfeed2imap-go-5c29e49f9f422c8889ce2ed6b5b5a2914b55cace.tar.gz
feed2imap-go-5c29e49f9f422c8889ce2ed6b5b5a2914b55cace.tar.bz2
feed2imap-go-5c29e49f9f422c8889ce2ed6b5b5a2914b55cace.zip
Support feed targets per feed
Diffstat (limited to 'internal/imap')
-rw-r--r--internal/imap/folder.go4
-rw-r--r--internal/imap/imap.go9
2 files changed, 6 insertions, 7 deletions
diff --git a/internal/imap/folder.go b/internal/imap/folder.go
index 9386293..32bfefe 100644
--- a/internal/imap/folder.go
+++ b/internal/imap/folder.go
@@ -7,6 +7,10 @@ type Folder struct {
delimiter string
}
+func (f Folder) IsBlank() bool {
+ return f.str == ""
+}
+
func (f Folder) String() string {
return f.str
}
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index 4a18a94..a44a513 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -2,7 +2,6 @@ package imap
import (
"fmt"
- "strings"
"github.com/Necoro/feed2imap-go/pkg/config"
"github.com/Necoro/feed2imap-go/pkg/log"
@@ -31,15 +30,11 @@ func Connect(url config.Url) (*Client, error) {
}
client.delimiter = delim
- toplevel := url.Root
- if toplevel[0] == '/' {
- toplevel = toplevel[1:]
- }
- client.toplevel = client.folderName(strings.Split(toplevel, "/"))
+ client.toplevel = client.folderName(url.RootPath())
log.Printf("Determined '%s' as toplevel, with '%s' as delimiter", client.toplevel, client.delimiter)
- if toplevel != "" {
+ if !client.toplevel.IsBlank() {
if err = conn.ensureFolder(client.toplevel); err != nil {
return nil, err
}