re-enabled enabling/disabled services
This commit is contained in:
parent
50c8d3baf2
commit
7f78103ce5
4 changed files with 107 additions and 67 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
// Global variables
|
||||
var ThisSession Session
|
||||
var MainConfig Config
|
||||
|
||||
const defaultConfigDir string = "default-config/"
|
||||
const configDir string = "config/"
|
||||
|
||||
|
@ -33,6 +34,7 @@ func loadConfig() Config {
|
|||
fmt.Println("Loading Custom Services…")
|
||||
customsvcfile := configDir + "services.yaml"
|
||||
unmarshalConfig(customsvcfile, &cfg)
|
||||
removeDisabledItems(&cfg)
|
||||
return cfg
|
||||
}
|
||||
|
||||
|
@ -44,12 +46,36 @@ func unmarshalConfig(file string, cfg *Config) {
|
|||
}
|
||||
err2 := yaml.Unmarshal(content, &cfg)
|
||||
if err2 != nil {
|
||||
fmt.Println("Error unmarshalling config :", file, " : ", err2)
|
||||
fmt.Println("Error unmarshaling config :", file, " : ", err2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func removeDisabledItems(cfg *Config) {
|
||||
// Rework this, not pretty
|
||||
if !cfg.InMail.Enabled {
|
||||
cfg.InMail = Service{}
|
||||
}
|
||||
if !cfg.OutMail.Enabled {
|
||||
cfg.OutMail = Service{}
|
||||
}
|
||||
if !cfg.Calendar.Enabled {
|
||||
cfg.Calendar = Service{}
|
||||
}
|
||||
if !cfg.AddressBook.Enabled {
|
||||
cfg.AddressBook = Service{}
|
||||
}
|
||||
if !cfg.WebMail.Enabled {
|
||||
cfg.WebMail = Service{}
|
||||
}
|
||||
new_svcs := []Service{}
|
||||
for _,svc := range cfg.OtherServices {
|
||||
if svc.Enabled {
|
||||
new_svcs = append(new_svcs,svc)
|
||||
}
|
||||
}
|
||||
cfg.OtherServices = new_svcs
|
||||
}
|
||||
func FileExists(file string) bool {
|
||||
exists := false
|
||||
if _, err := os.Stat(file); err == nil {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
{{ end }}
|
||||
<displayName>{{ .Email }}</displayName>
|
||||
{{ with .Config.InMail }}
|
||||
{{ if .Enabled }}
|
||||
<incomingServer type="{{ .Type | lower }}">
|
||||
<hostname>{{ .Server }}</hostname>
|
||||
<port>{{ .Port }}</port>
|
||||
|
@ -12,7 +13,9 @@
|
|||
<authentication>{{ .Authentication }}</authentication>
|
||||
</incomingServer>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.OutMail }}
|
||||
{{ if .Enabled }}
|
||||
<outgoingServer type="{{ .Type | lower }}">
|
||||
<hostname>{{ .Server }}</hostname>
|
||||
<port>{{ .Port }}></port>
|
||||
|
@ -21,21 +24,27 @@
|
|||
<authentication>{{ .Authentication }}</authentication>
|
||||
</outgoingServer>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.AddressBook }}
|
||||
{{ if .Enabled }}
|
||||
<addressBook type="{{ .Type | lower }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
<serverURL>{{ .Server }}</serverURL>
|
||||
</addressBook>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.Calendar }}
|
||||
{{ if .Enabled }}
|
||||
<calendar type="{{ .Type | lower }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
<serverURL>{{ .Server }}</serverURL>
|
||||
</calendar>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.WebMail }}
|
||||
{{ if .Enabled }}
|
||||
<webMail>
|
||||
<loginPage url="{{ .Server }}" />
|
||||
<loginPageInfo url="{{ .Server }}">
|
||||
|
@ -46,5 +55,6 @@
|
|||
</loginPageInfo>
|
||||
</webMail>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</emailProvider>
|
||||
</clientConfig>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<AccountType>email</AccountType>
|
||||
<Action>settings</Action>
|
||||
{{ with .Config.InMail }}
|
||||
{{ if .Enabled }}
|
||||
<Protocol>
|
||||
<Type>{{ .Type }}</Type>
|
||||
<Server>{{ .Server }}</Server>
|
||||
|
@ -16,7 +17,9 @@
|
|||
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
||||
</Protocol>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.OutMail }}
|
||||
{{ if .Enabled }}
|
||||
<Protocol>
|
||||
<Type>{{ .Type }}</Type>
|
||||
<Server>{{ .Server }}</Server>
|
||||
|
@ -30,6 +33,7 @@
|
|||
<SMTPLast>{{ .SMTPLast | onoff }}</SMTPLast>
|
||||
</Protocol>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</Account>
|
||||
</Response>
|
||||
</Autodiscover>
|
||||
|
|
|
@ -81,7 +81,7 @@ func OurConfig() string {
|
|||
}
|
||||
func parseUsername(svc Service) string {
|
||||
if email == "" {
|
||||
return "<!-- not provided -->"
|
||||
return "not-provided"
|
||||
}
|
||||
if svc.UsernameIsFQDN && !svc.RequireLocalDomain{
|
||||
return email
|
||||
|
|
Loading…
Reference in a new issue