/
config.go
71 lines (62 loc) · 1.66 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package mail2most
import (
"os"
"github.com/BurntSushi/toml"
)
type config struct {
General general
Logging logging
Profiles []profile `toml:"Profile"`
DefaultProfile profile
}
type general struct {
File string
RunAsService bool
TimeInterval uint
}
type logging struct {
Loglevel string
Logtype string
Logfile string
Output string
}
type profile struct {
IgnoreDefaults bool
Mail maildata
Mattermost mattermost
Filter filter
}
type maildata struct {
ImapServer, Username, Password string
ReadOnly bool
ImapTLS bool
VerifyTLS bool
Limit uint32
}
type filter struct {
Folders, From, To, Subject []string
Unseen bool
TimeRange string
IgnoreMailErrorNotifications bool
}
type mattermost struct {
URL, Team, Username, Password, AccessToken string
Channels []string
Users []string
Broadcast []string
SubjectOnly bool
BodyOnly bool
StripHTML bool
ConvertToMarkdown bool
HideFrom bool
HideFromEmail bool
MailAttachments bool
BodyPrefix, BodySuffix string
}
func parseConfig(fileName string, conf *config) error {
if _, err := os.Stat(fileName); os.IsNotExist(err) {
return err
}
_, err := toml.DecodeFile(fileName, conf)
return err
}