commit 5b3e219274190a9270640d143a924ab1ffe7c02d
parent 60308cb524acbe417a7272a0991cd46026a15e38
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Sat, 25 Jan 2025 21:22:35 +0100
refactor capitalization of all structs
Diffstat:
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
@@ -214,7 +214,7 @@ type RegisterMessage struct {
// Entry is a mapping from the identity key hash to a wallet key
// The identity key hash is sha512(sha512(address)|salt) where identity is
// one of the identity key types supported (e.g. an email address)
-type entry struct {
+type Entry struct {
// ORM
gorm.Model `json:"-"`
@@ -230,10 +230,10 @@ type entry struct {
}
// Validation is the object created when a registration for an entry is initiated.
-// The validation stores the identity key (sha256(identity)) the secret
-// validation reference. The validation reference is sent to the identity
+// The Validation stores the identity key (sha256(identity)) the secret
+// Validation reference. The Validation reference is sent to the identity
// depending on the out-of-band chennel defined through the identity key type.
-type validation struct {
+type Validation struct {
// ORM
gorm.Model `json:"-"`
@@ -348,7 +348,7 @@ func (v *Validator) isAliasValid(alias string) (err error) {
// identity, e.g. SHA512(<email address>)
func (t *Taldir) getSingleEntry(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
- var entry entry
+ var entry Entry
hsAddress := saltHAddress(vars["h_address"], t.Salt)
var err = t.Db.First(&entry, "hs_address = ?", hsAddress).Error
if err == nil {
@@ -373,8 +373,8 @@ func saltHAddress(hAddress string, salt string) string {
// provided "out of band" using a validation method such as email or SMS
func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
- var entry entry
- var validation validation
+ var entry Entry
+ var validation Validation
var confirm ValidationConfirmation
var errDetail ErrorDetail
if r.Body == nil {
@@ -450,7 +450,7 @@ func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request) {
}
func (t *Taldir) isRateLimited(hAddress string) (bool, error) {
- var validations []validation
+ var validations []Validation
res := t.Db.Where("h_address = ?", hAddress).Find(&validations)
// NOTE: Check rate limit
if res.Error == nil {
@@ -465,8 +465,8 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
var req RegisterMessage
var errDetail ErrorDetail
- var validation validation
- var entry entry
+ var validation Validation
+ var entry Entry
// Check if this validation method is supported or not.
validator, ok := t.Validators[vars["method"]]
if !ok {
@@ -656,7 +656,7 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) {
var walletLink string
var address string
var png []byte
- var validation validation
+ var validation Validation
log.Println("Validation Page")
err := t.Db.First(&validation, "h_address = ?", vars["h_address"]).Error
@@ -733,8 +733,8 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) {
// ClearDatabase nukes the database (for tests)
func (t *Taldir) ClearDatabase() {
- t.Db.Where("1 = 1").Delete(&entry{})
- t.Db.Where("1 = 1").Delete(&validation{})
+ t.Db.Where("1 = 1").Delete(&Entry{})
+ t.Db.Where("1 = 1").Delete(&Validation{})
}
func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) {
@@ -782,7 +782,7 @@ func (t *Taldir) imprintPage(w http.ResponseWriter, r *http.Request) {
}
func (t *Taldir) methodLookupResultPage(w http.ResponseWriter, r *http.Request) {
- var entry entry
+ var entry Entry
vars := mux.Vars(r)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@@ -972,15 +972,15 @@ func (t *Taldir) Initialize(cfgfile string, version string) {
panic(err)
}
t.Db = _db
- if err := t.Db.AutoMigrate(&entry{}); err != nil {
+ if err := t.Db.AutoMigrate(&Entry{}); err != nil {
panic(err)
}
- if err := t.Db.AutoMigrate(&validation{}); err != nil {
+ if err := t.Db.AutoMigrate(&Validation{}); err != nil {
panic(err)
}
if t.Cfg.Section("taldir").Key("purge_mappings_on_startup_dangerous").MustBool(false) {
log.Println("DANGER Purging mappings!")
- tx := t.Db.Where("1 = 1").Delete(&entry{})
+ tx := t.Db.Where("1 = 1").Delete(&Entry{})
log.Printf("Deleted %d entries.\n", tx.RowsAffected)
}
// Clean up validations
@@ -992,7 +992,7 @@ func (t *Taldir) Initialize(cfgfile string, version string) {
}
go func() {
for true {
- tx := t.Db.Where("created_at < ?", time.Now().Add(-validationExp)).Delete(&validation{})
+ tx := t.Db.Where("created_at < ?", time.Now().Add(-validationExp)).Delete(&Validation{})
log.Printf("Cleaned up %d stale validations.\n", tx.RowsAffected)
time.Sleep(validationExp)
}