aboutsummaryrefslogtreecommitdiff
path: root/internal/imap/folder.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-23 20:48:17 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-23 20:48:17 +0200
commitc883470c2ef977b8675b12428591bb003694e235 (patch)
tree09cd8fa950594e1ea13aa52492ce8116e07ef30b /internal/imap/folder.go
parent6bd87a567ef481b922f6baec2b475ec376c45443 (diff)
downloadfeed2imap-go-c883470c2ef977b8675b12428591bb003694e235.tar.gz
feed2imap-go-c883470c2ef977b8675b12428591bb003694e235.tar.bz2
feed2imap-go-c883470c2ef977b8675b12428591bb003694e235.zip
Restructure imap pkg
Diffstat (limited to '')
-rw-r--r--internal/imap/folder.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/imap/folder.go b/internal/imap/folder.go
new file mode 100644
index 0000000..1f4e0bf
--- /dev/null
+++ b/internal/imap/folder.go
@@ -0,0 +1,33 @@
+package imap
+
+import "strings"
+
+type Folder struct {
+ str string
+ delimiter string
+}
+
+func (f Folder) String() string {
+ return f.str
+}
+
+func (f Folder) Append(other Folder) Folder {
+ if f.delimiter != other.delimiter {
+ panic("Delimiters do not match")
+ }
+ return Folder{
+ str: f.str + f.delimiter + other.str,
+ delimiter: f.delimiter,
+ }
+}
+
+func (client *Client) folderName(path []string) Folder {
+ return Folder{
+ strings.Join(path, client.delimiter),
+ client.delimiter,
+ }
+}
+
+func (client *Client) NewFolder(path []string) Folder {
+ return client.toplevel.Append(client.folderName(path))
+}