diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f50ad1f2981ec..d7fc9398044e9 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3296,6 +3296,13 @@ config.send_test_mail_submit = Send config.test_mail_failed = Failed to send a testing email to "%s": %v config.test_mail_sent = A testing email has been sent to "%s". +config.incoming_mail_config = Incoming Mail Configuration +config.incoming_mail_enabled = Enabled +config.incoming_mail_test = Test Incoming Mail +config.incoming_mail_test_btn = Test +config.incoming_mail_description = Test Description +config.incoming_mail_result = Test Result + config.oauth_config = OAuth Configuration config.oauth_enabled = Enabled diff --git a/routers/web/admin/config.go b/routers/web/admin/config.go index d067250a5b6b0..80891bc71ba72 100644 --- a/routers/web/admin/config.go +++ b/routers/web/admin/config.go @@ -9,6 +9,7 @@ import ( "net/url" "strconv" "strings" + "time" system_model "code.gitea.io/gitea/models/system" "code.gitea.io/gitea/modules/base" @@ -26,10 +27,16 @@ import ( ) const ( - tplConfig base.TplName = "admin/config" - tplConfigSettings base.TplName = "admin/config_settings" + tplConfig base.TplName = "admin/config" + tplConfigIncomingMailTestResult base.TplName = "admin/config_incoming_mail_test_result" + tplConfigSettings base.TplName = "admin/config_settings" ) +var incomingMailResult struct { + Time int64 + Result string +} + // SendTestMail send test mail to confirm mail service is OK func SendTestMail(ctx *context.Context) { email := ctx.FormString("email") @@ -43,6 +50,21 @@ func SendTestMail(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + "/-/admin/config") } +// TestIncomingMail ... +func TestIncomingMail(ctx *context.Context) { + log.Trace("call TestIncomingMail") + incomingMailResult.Time = time.Now().Unix() + incomingMailResult.Result = "ok" + ctx.Redirect(setting.AppSubURL + "/-/admin/config") +} + +// IncomingMail ... +func IncomingMail(ctx *context.Context) { + log.Trace("call IncomingMail") + ctx.Data["IncomingMailResult"] = incomingMailResult + ctx.HTML(http.StatusOK, tplConfigIncomingMailTestResult) +} + // TestCache test the cache settings func TestCache(ctx *context.Context) { elapsed, err := cache.Test() @@ -152,6 +174,13 @@ func Config(ctx *context.Context) { ctx.Data["Mailer"] = setting.MailService } + ctx.Data["IncomingMailEnabled"] = false + if setting.MailService != nil && setting.IncomingEmail.Enabled { + ctx.Data["IncomingMailEnabled"] = true + } + ctx.Data["IncomingMail"] = setting.IncomingEmail + ctx.Data["IncomingMailResult"] = incomingMailResult + ctx.Data["CacheAdapter"] = setting.CacheService.Adapter ctx.Data["CacheInterval"] = setting.CacheService.Interval diff --git a/routers/web/web.go b/routers/web/web.go index 72ee47bb4c962..9ccdc8fb5ea1c 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -712,8 +712,12 @@ func registerRoutes(m *web.Router) { m.Group("/config", func() { m.Get("", admin.Config) m.Post("", admin.ChangeConfig) - m.Post("/test_mail", admin.SendTestMail) - m.Post("/test_cache", admin.TestCache) + m.Group("/test", func() { + m.Post("/mail", admin.SendTestMail) + m.Get("/incoming-mail", admin.IncomingMail) + m.Post("/incoming-mail", admin.TestIncomingMail) + m.Post("/cache", admin.TestCache) + }) m.Get("/settings", admin.ConfigSettings) }) diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 29a5e1b473d3b..d132387eb5582 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -231,7 +231,7 @@