update
parent
977436d334
commit
44f1c38811
|
@ -2,9 +2,12 @@ package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"kumoly.io/kumoly/app/auth"
|
"kumoly.io/kumoly/app/auth"
|
||||||
|
"kumoly.io/kumoly/app/email"
|
||||||
|
"kumoly.io/kumoly/app/errors"
|
||||||
"kumoly.io/kumoly/app/server"
|
"kumoly.io/kumoly/app/server"
|
||||||
"kumoly.io/kumoly/app/system"
|
"kumoly.io/kumoly/app/system"
|
||||||
"kumoly.io/kumoly/app/task"
|
"kumoly.io/kumoly/app/task"
|
||||||
|
@ -31,14 +34,36 @@ func (srv Service) Load() error {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
data := map[string]interface{}{}
|
data := map[string]interface{}{}
|
||||||
if err := json.Unmarshal([]byte(conf), data); err != nil {
|
if err := json.Unmarshal([]byte(conf), &data); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
server.OK(c, data)
|
server.OK(c, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ctlAPI.GET("test_email", auth.ACAdmin(), func(c *gin.Context) {
|
||||||
|
tos := c.Query("to")
|
||||||
|
if tos == "" {
|
||||||
|
panic(errors.ErrorBadRequest)
|
||||||
|
}
|
||||||
|
to := strings.Split(tos, ",")
|
||||||
|
if err := email.Send("test@kumoly.io", to, "Test Email", &email.Body{
|
||||||
|
Greeting: "Dear",
|
||||||
|
Receiver: "Administrator",
|
||||||
|
Intros: []string{
|
||||||
|
"This is a test email.",
|
||||||
|
},
|
||||||
|
}); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
server.OK(c, "email sent.")
|
||||||
|
})
|
||||||
|
|
||||||
|
// this should be in task service
|
||||||
ctlAPI.GET("tasks", auth.ACAdmin(), func(c *gin.Context) {
|
ctlAPI.GET("tasks", auth.ACAdmin(), func(c *gin.Context) {
|
||||||
server.OK(c, task.GetProfile())
|
server.OK(c, task.GetProfile())
|
||||||
})
|
})
|
||||||
|
ctlAPI.GET("task", auth.ACAdmin(), func(c *gin.Context) {
|
||||||
|
server.OK(c, task.GetTasks())
|
||||||
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ func init() {
|
||||||
viper.SetDefault("email.port", 587)
|
viper.SetDefault("email.port", 587)
|
||||||
viper.SetDefault("email.username", "test@kumoly.io")
|
viper.SetDefault("email.username", "test@kumoly.io")
|
||||||
viper.SetDefault("email.password", "test")
|
viper.SetDefault("email.password", "test")
|
||||||
|
viper.SetDefault("logo", "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
|
@ -21,15 +22,21 @@ type App struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Body struct {
|
type Body struct {
|
||||||
|
// App replaced with global config
|
||||||
App App
|
App App
|
||||||
Intros []string
|
|
||||||
Outros []string
|
|
||||||
Content string
|
|
||||||
|
|
||||||
|
Intros []string
|
||||||
|
Content string
|
||||||
|
Outros []string
|
||||||
|
|
||||||
|
// Greeting ignored if empty
|
||||||
Greeting string
|
Greeting string
|
||||||
|
// Receiver ignored if Greeting or Receiver empty
|
||||||
Receiver string
|
Receiver string
|
||||||
|
|
||||||
|
// Signature default `Best Regards`
|
||||||
Signature string
|
Signature string
|
||||||
|
// Sender default {{.App.Name}}
|
||||||
Sender string
|
Sender string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ func (srv *Service) Init() error {
|
||||||
app.Copyright = fmt.Sprintf("Copyright © %v %s. All rights reserved.",
|
app.Copyright = fmt.Sprintf("Copyright © %v %s. All rights reserved.",
|
||||||
time.Now().Year(), app.Name)
|
time.Now().Year(), app.Name)
|
||||||
app.Link = viper.GetString("server.url")
|
app.Link = viper.GetString("server.url")
|
||||||
|
app.Logo = viper.GetString("logo")
|
||||||
|
|
||||||
dial = gomail.NewDialer(
|
dial = gomail.NewDialer(
|
||||||
viper.GetString("email.host"),
|
viper.GetString("email.host"),
|
||||||
|
|
Loading…
Reference in New Issue