GetServerConfig returns general server config.
(c echo.Context)
| 40 | |
| 41 | // GetServerConfig returns general server config. |
| 42 | func (a *App) GetServerConfig(c echo.Context) error { |
| 43 | out := serverConfig{ |
| 44 | RootURL: a.urlCfg.RootURL, |
| 45 | FromEmail: a.cfg.FromEmail, |
| 46 | Lang: a.cfg.Lang, |
| 47 | Permissions: a.cfg.PermissionsRaw, |
| 48 | HasLegacyUser: a.cfg.HasLegacyUser, |
| 49 | Privacy: struct { |
| 50 | DisableTracking bool `json:"disable_tracking"` |
| 51 | IndividualTracking bool `json:"individual_tracking"` |
| 52 | }{ |
| 53 | DisableTracking: a.cfg.Privacy.DisableTracking, |
| 54 | IndividualTracking: a.cfg.Privacy.IndividualTracking, |
| 55 | }, |
| 56 | } |
| 57 | out.PublicSubscription.Enabled = a.cfg.EnablePublicSubPage |
| 58 | for _, d := range a.cfg.Security.TrustedURLs { |
| 59 | if d == "*" { |
| 60 | continue |
| 61 | } |
| 62 | out.PublicSubscription.RedirectURLs = append(out.PublicSubscription.RedirectURLs, d) |
| 63 | } |
| 64 | |
| 65 | // CAPTCHA. |
| 66 | if a.cfg.Security.Captcha.Altcha.Enabled { |
| 67 | out.PublicSubscription.CaptchaEnabled = true |
| 68 | out.PublicSubscription.CaptchaProvider = null.StringFrom(captcha.ProviderAltcha) |
| 69 | out.PublicSubscription.AltchaComplexity = a.cfg.Security.Captcha.Altcha.Complexity |
| 70 | } else if a.cfg.Security.Captcha.HCaptcha.Enabled { |
| 71 | out.PublicSubscription.CaptchaEnabled = true |
| 72 | out.PublicSubscription.CaptchaProvider = null.StringFrom(captcha.ProviderHCaptcha) |
| 73 | out.PublicSubscription.CaptchaKey = null.StringFrom(a.cfg.Security.Captcha.HCaptcha.Key) |
| 74 | } |
| 75 | |
| 76 | out.MediaProvider = a.cfg.MediaUpload.Provider |
| 77 | |
| 78 | // Language list. |
| 79 | langList, err := getI18nLangList(a.fs) |
| 80 | if err != nil { |
| 81 | return echo.NewHTTPError(http.StatusInternalServerError, |
| 82 | fmt.Sprintf("Error loading language list: %v", err)) |
| 83 | } |
| 84 | out.Langs = langList |
| 85 | |
| 86 | out.Messengers = make([]string, 0, len(a.messengers)) |
| 87 | for _, m := range a.messengers { |
| 88 | out.Messengers = append(out.Messengers, m.Name()) |
| 89 | } |
| 90 | |
| 91 | a.Lock() |
| 92 | out.NeedsRestart = a.needsRestart |
| 93 | out.Update = a.update |
| 94 | a.Unlock() |
| 95 | out.Version = versionString |
| 96 | |
| 97 | return c.JSON(http.StatusOK, okResp{out}) |
| 98 | } |
| 99 |
nothing calls this directly
no test coverage detected