diff --git a/core/api.go b/core/api.go index 5039810..f7ac026 100644 --- a/core/api.go +++ b/core/api.go @@ -397,6 +397,30 @@ func (caller apiCaller) configAPI(w http.ResponseWriter, r *http.Request) error return nil } +func (caller apicaller) lockcreatecharAPI(w http.ResponseWriter, r *http.Request) error { + mg, err := caller.mg.mongoClient.FindAll(CollectionService, bson.M{}) + if err != nil { + return err + } + + curregion, _ := gocommon.ReadStringFormValue(r.Form, "region") + + for _, regioninfo := range mg { + region := regioninfo["divisions"].(primitive.M) + for idx, rl := range region { + if idx == curregion { + if rl.(primitive.M)["lockcreatechar"].(bool) { + w.Write([]byte(fmt.Sprintf(`{"create":"%t"}`, true))) + } else { + w.Write([]byte(fmt.Sprintf(`{"create":"%t"}`, false))) + } + } + } + } + + return nil +} + type apiCaller struct { userinfo map[string]any globalAdmins map[string]bool @@ -503,6 +527,8 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) { err = caller.blockAPI(w, r) } else if strings.HasSuffix(r.URL.Path, "/coupon") { err = caller.couponAPI(w, r) + } else if strings.HasSuffix(r.URL.Path, "/lockcreatechar") { + err = caller.lockcreatecharAPI(w, r) } if err != nil {