taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

commit 7255d981d0789fb10e4d245766fb23a3fbd773ef
parent 5b99c13bc1da8a8b05dfb3cc7aba7c145fadf6ef
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Sat, 26 Apr 2025 15:31:07 +0200

update TOS handling form taler-go 1.1.0

Diffstat:
Mgo.mod | 2+-
Mgo.sum | 4++--
Mpkg/rest/taldir.go | 40++++++++++++++++++++++++++--------------
3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/go.mod b/go.mod @@ -6,7 +6,7 @@ require ( github.com/gertd/go-pluralize v0.2.1 github.com/gorilla/mux v1.8.1 github.com/kataras/i18n v0.0.8 - github.com/schanzen/taler-go v1.0.8 + github.com/schanzen/taler-go v1.1.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e gnunet v0.1.27 gopkg.in/ini.v1 v1.67.0 diff --git a/go.sum b/go.sum @@ -32,8 +32,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/schanzen/taler-go v1.0.8 h1:vrFtYpE2hgfMrft/hzv3O1NjtjDOF0I44ossRw7pLT0= -github.com/schanzen/taler-go v1.0.8/go.mod h1:+l2TVAPZkF2d15X/XPLYZI5R6PdW6gc6Wft12jrl7tA= +github.com/schanzen/taler-go v1.1.0 h1:FRCY1XwrefuGpb1YVRL2HnMHwrLI9UsX2nKdVLfSM1I= +github.com/schanzen/taler-go v1.1.0/go.mod h1:+l2TVAPZkF2d15X/XPLYZI5R6PdW6gc6Wft12jrl7tA= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go @@ -752,11 +752,23 @@ func (t *Taldir) ClearDatabase() { } func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) { - tos.ServiceTermsResponse(t.Cfg.Ini.Section("taldir"), w, r) + s := t.Cfg.Ini.Section("taldir") + termspath := t.getFileName(s.Key("default_terms_path").MustString("terms/")) + tos.ServiceTermsResponse(w, r, termspath, tos.TalerTosConfig{ + DefaultFileType: s.Key("default_doc_filetype").MustString("text/html"), + DefaultLanguage: s.Key("default_doc_lang").MustString("en"), + SupportedFileTypes: strings.Split(s.Key("supported_doc_filetypes").String(), " "), + }) } func (t *Taldir) privacyResponse(w http.ResponseWriter, r *http.Request) { - tos.PrivacyPolicyResponse(t.Cfg.Ini.Section("taldir"), w, r) + s := t.Cfg.Ini.Section("mailbox") + pppath := t.getFileName(s.Key("default_pp_path").MustString("privacy/")) + tos.PrivacyPolicyResponse(w, r, pppath, tos.TalerTosConfig{ + DefaultFileType: s.Key("default_doc_filetype").MustString("text/html"), + DefaultLanguage: s.Key("default_doc_lang").MustString("en"), + SupportedFileTypes: strings.Split(s.Key("supported_doc_filetypes").String(), " "), + }) } func (t *Taldir) landingPage(w http.ResponseWriter, r *http.Request) { @@ -925,15 +937,15 @@ func getFuncs(current *i18n.Locale) template.FuncMap { } } -func (t *Taldir) getFileName(relativeFileName string, datahome string) string { +func (t *Taldir) getFileName(relativeFileName string) string { _, err := os.Stat(relativeFileName) if errors.Is(err, os.ErrNotExist) { - _, err := os.Stat(datahome + "/" + relativeFileName) + _, err := os.Stat(t.Cfg.Datahome + "/" + relativeFileName) if errors.Is(err, os.ErrNotExist) { - log.Printf("Tried fallback not found %s\n", datahome+"/"+relativeFileName) + log.Printf("Tried fallback not found %s\n", t.Cfg.Datahome+"/"+relativeFileName) return "" } - return datahome + "/" + relativeFileName + return t.Cfg.Datahome + "/" + relativeFileName } return relativeFileName } @@ -954,8 +966,8 @@ func (t *Taldir) Initialize(cfg TaldirConfig) { fmt.Println("Production mode enabled") } - navTplFile := cfg.Ini.Section("taldir").Key("navigation").MustString(t.getFileName("web/templates/nav.html", cfg.Datahome)) - footerTplFile := cfg.Ini.Section("taldir").Key("footer").MustString(t.getFileName("web/templates/footer.html", cfg.Datahome)) + navTplFile := cfg.Ini.Section("taldir").Key("navigation").MustString(t.getFileName("web/templates/nav.html")) + footerTplFile := cfg.Ini.Section("taldir").Key("footer").MustString(t.getFileName("web/templates/footer.html")) t.BaseUrl = cfg.Ini.Section("taldir").Key("base_url").MustString("http://localhost:11000") t.Validators = make(map[string]Validator) for _, sec := range cfg.Ini.Sections() { @@ -967,7 +979,7 @@ func (t *Taldir) Initialize(cfg TaldirConfig) { continue } vname := strings.TrimPrefix(sec.Name(), "taldir-validator-") - vlandingPageTplFile := sec.Key("registration_page").MustString(t.getFileName("web/templates/landing_"+vname+".html", cfg.Datahome)) + vlandingPageTplFile := sec.Key("registration_page").MustString(t.getFileName("web/templates/landing_"+vname+".html")) vlandingPageTpl, err := template.ParseFiles(vlandingPageTplFile, navTplFile, footerTplFile) if err != nil { log.Printf("`%s` template not found, disabling validator `%s`.\n", vlandingPageTplFile, vname) @@ -1035,31 +1047,31 @@ func (t *Taldir) Initialize(cfg TaldirConfig) { time.Sleep(validationExp) } }() - imprintTplFile := cfg.Ini.Section("taldir").Key("imprint_page").MustString(t.getFileName("web/templates/imprint.html", cfg.Datahome)) + imprintTplFile := cfg.Ini.Section("taldir").Key("imprint_page").MustString(t.getFileName("web/templates/imprint.html")) t.ImprintTpl, err = template.ParseFiles(imprintTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) } - validationLandingTplFile := cfg.Ini.Section("taldir").Key("validation_landing").MustString(t.getFileName("web/templates/validation_landing.html", cfg.Datahome)) + validationLandingTplFile := cfg.Ini.Section("taldir").Key("validation_landing").MustString(t.getFileName("web/templates/validation_landing.html")) t.ValidationTpl, err = template.ParseFiles(validationLandingTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) } - landingTplFile := cfg.Ini.Section("taldir").Key("landing_page").MustString(t.getFileName("web/templates/landing.html", cfg.Datahome)) + landingTplFile := cfg.Ini.Section("taldir").Key("landing_page").MustString(t.getFileName("web/templates/landing.html")) t.LandingPageTpl, err = template.ParseFiles(landingTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) } - lookupResultTplFile := cfg.Ini.Section("taldir").Key("lookup_result_page").MustString(t.getFileName("web/templates/lookup_result.html", cfg.Datahome)) + lookupResultTplFile := cfg.Ini.Section("taldir").Key("lookup_result_page").MustString(t.getFileName("web/templates/lookup_result.html")) t.LookupResultPageTpl, err = template.ParseFiles(lookupResultTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) } - aboutTplFile := cfg.Ini.Section("taldir").Key("about_page").MustString(t.getFileName("web/templates/about.html", cfg.Datahome)) + aboutTplFile := cfg.Ini.Section("taldir").Key("about_page").MustString(t.getFileName("web/templates/about.html")) t.AboutPageTpl, err = template.ParseFiles(aboutTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err)