commit 879ec5c27464363731de492b7e9ba446fdae75fe
parent 43475d79eca8b4ae392374e09e58b16397d80c78
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Sat, 9 Dec 2023 22:18:59 +0100
Make summary message configurable
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/gns-registrar.conf b/gns-registrar.conf
@@ -1,6 +1,6 @@
[gns-registrar]
production = false
-base_url = "http://localhost:7776"
+base_url = "http://localhost:11000"
base_url_gnunet = "http://localhost:7776"
gnunet_auth = ""
base_url_merchant = https://backend.demo.taler.net
diff --git a/pkg/rest/gnsregistrar.go b/pkg/rest/gnsregistrar.go
@@ -125,6 +125,9 @@ type Registrar struct {
// Registrar base URL
BaseUrl string
+
+ // The template to use for the summary string
+ SummaryTemplateString string
// Cost for a registration
RegistrationCost *talerutil.Amount
@@ -345,7 +348,8 @@ func (t *Registrar) buyPage(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/name/"+vars["label"] + "?error=Registration failed: Pending buy order", http.StatusSeeOther)
return
}
- orderID, newOrderErr := t.Merchant.AddNewOrder(*t.RegistrationCost, "GNS registrar name registration", t.BaseUrl + "/name/" + vars["label"])
+ summaryMsg := strings.Replace(t.SummaryTemplateString, "${NAME}", vars["label"], 1)
+ orderID, newOrderErr := t.Merchant.AddNewOrder(*t.RegistrationCost, summaryMsg, t.BaseUrl + "/name/" + vars["label"])
if newOrderErr != nil {
fmt.Println(newOrderErr)
http.Redirect(w, r, "/name/"+vars["label"] + "?error=Registration failed: Unable to create order", http.StatusSeeOther)
@@ -563,9 +567,9 @@ func (t *Registrar) Initialize(cfgfile string) {
if err != nil {
fmt.Println(err)
}
- paymentExp := t.Cfg.Section("gns-registrar").Key("payment_required_expiration").MustString("48h")
+ paymentExp := t.Cfg.Section("gns-registrar").Key("payment_required_expiration").MustString("1h")
recordExp := t.Cfg.Section("gns-registrar").Key("relative_delegation_expiration").MustString("24h")
- registrationExp := t.Cfg.Section("gns-registrar").Key("registration_expiration").MustString("8760h")
+ registrationExp := t.Cfg.Section("gns-registrar").Key("registration_expiration").MustString("120h")
t.RelativeRegistrationExpiration, _ = time.ParseDuration(registrationExp)
t.RelativeDelegationExpiration, _ = time.ParseDuration(recordExp)
t.PaymentExpiration, _ = time.ParseDuration(paymentExp)
@@ -575,6 +579,7 @@ func (t *Registrar) Initialize(cfgfile string) {
t.RegistrationCost, err = talerutil.ParseAmount(costStr)
t.BaseUrl = t.Cfg.Section("gns-registrar").Key("base_url").MustString("http://localhost:11000")
t.SuffixHint = t.Cfg.Section("gns-registrar").Key("suffix_hint").MustString("example.alt")
+ t.SummaryTemplateString = t.Cfg.Section("gns-registrar").Key("order_summary_template").MustString("Registration of `${NAME}' at GNUnet FCFS registrar")
t.RootZoneName = t.Cfg.Section("gns-registrar").Key("root_zone_name").MustString("test")
t.GnunetUrl = t.Cfg.Section("gns-registrar").Key("base_url_gnunet").MustString("http://localhost:7776")
resp, err := http.Get(t.GnunetUrl + "/identity/name/" + t.RootZoneName)