newsletter option

pull/617/head
hunterlong 2020-06-01 19:27:31 -07:00
parent 8a3a1888cf
commit ee7960ebe7
1 changed files with 4 additions and 5 deletions

View File

@ -102,7 +102,7 @@ func processSetupHandler(w http.ResponseWriter, r *http.Request) {
core.App = c core.App = c
if sendNews { if sendNews {
log.Infoln("Sending email address to newsletter server") log.Infof("Sending email address %s to newsletter server", confgs.Email)
if err := registerNews(confgs.Email, confgs.Domain); err != nil { if err := registerNews(confgs.Email, confgs.Domain); err != nil {
log.Errorln(err) log.Errorln(err)
} }
@ -122,7 +122,7 @@ func processSetupHandler(w http.ResponseWriter, r *http.Request) {
CacheStorage.Delete("/") CacheStorage.Delete("/")
resetCookies() resetCookies()
time.Sleep(1 * time.Second) time.Sleep(2 * time.Second)
out := struct { out := struct {
Message string `json:"message"` Message string `json:"message"`
Config *configs.DbConfig `json:"config"` Config *configs.DbConfig `json:"config"`
@ -139,10 +139,9 @@ func registerNews(email, domain string) error {
v.Set("domain", domain) v.Set("domain", domain)
v.Set("timezone", "UTC") v.Set("timezone", "UTC")
rb := strings.NewReader(v.Encode()) rb := strings.NewReader(v.Encode())
resp, err := http.Post("https://news.statping.com/new", "application/x-www-form-urlencoded", rb)
_, _, err := utils.HttpRequest("https://news.statping.com/new", "POST", nil, nil, rb, 10*time.Second, true, nil)
if err != nil { if err != nil {
return err return err
} }
return nil return resp.Body.Close()
} }