gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taldir] branch master updated: handle missing scripts better


From: gnunet
Subject: [taler-taldir] branch master updated: handle missing scripts better
Date: Wed, 06 Jul 2022 18:56:04 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository taldir.

The following commit(s) were added to refs/heads/master by this push:
     new eac62d8  handle missing scripts better
eac62d8 is described below

commit eac62d894b2e185fdaecb4a62e274951a52a27eb
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Wed Jul 6 18:56:01 2022 +0200

    handle missing scripts better
---
 cmd/taldir-server/main.go | 39 +++++++++++++++++++++++----------------
 taldir.conf               |  2 +-
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/cmd/taldir-server/main.go b/cmd/taldir-server/main.go
index 61d5c82..b2ef3f7 100644
--- a/cmd/taldir-server/main.go
+++ b/cmd/taldir-server/main.go
@@ -359,24 +359,24 @@ func registerRequest(w http.ResponseWriter, r 
*http.Request){
     }
   }
   err = db.First(&validation, "h_address = ?", validation.HAddress).Error
+  validation.Code = util.GenerateCode()
+  validation.Inbox = req.Inbox
+  validation.Duration = req.Duration
+  validation.PublicKey = req.PublicKey
   if err == nil {
     // FIXME: Validation already pending for this address
     // How should we proceed here? Expire old validations?
-    w.WriteHeader(202)
-    return
-  } else {
-    validation.Code = util.GenerateCode()
-    validation.Inbox = req.Inbox
-    validation.Duration = req.Duration
-    validation.PublicKey = req.PublicKey
+    log.Println("Validation for this address already exists")
+    err = db.Save(&validation).Error
+  } else  {
     err = db.Create(&validation).Error
-    if err != nil {
-      // FIXME: API needs 400 error codes in such cases
-      w.WriteHeader(http.StatusInternalServerError)
-      return
-    }
-    fmt.Println("Address registration request created:", validation)
   }
+  if err != nil {
+    // FIXME: API needs 400 error codes in such cases
+    w.WriteHeader(http.StatusInternalServerError)
+    return
+  }
+  fmt.Println("Address registration request created:", validation)
   if !cfg.Section("taldir-" + vars["method"]).HasKey("command") {
     log.Fatal(err)
     db.Delete(&validation)
@@ -384,15 +384,22 @@ func registerRequest(w http.ResponseWriter, r 
*http.Request){
     return
   }
   command := cfg.Section("taldir-" + vars["method"]).Key("command").String()
-  out, err := exec.Command(command, req.Address, validation.Code).Output()
+  path, err := exec.LookPath(command)
   if err != nil {
-    log.Fatal(err)
+    log.Println(err)
+    db.Delete(&validation)
+    w.WriteHeader(500)
+    return
+  }
+  out, err := exec.Command(path, req.Address, validation.Code).Output()
+  if err != nil {
+    log.Println(err)
     db.Delete(&validation)
     w.WriteHeader(500)
     return
   }
   w.WriteHeader(202)
-  fmt.Printf("Output from method script is %s\n", out)
+  fmt.Printf("Output from method script %s is %s\n", path, out)
 }
 
 func notImplemented(w http.ResponseWriter, r *http.Request) {
diff --git a/taldir.conf b/taldir.conf
index a134a38..9560e77 100644
--- a/taldir.conf
+++ b/taldir.conf
@@ -19,7 +19,7 @@ command = validate_phone.sh
 
 [taldir-test]
 challenge_fee = KUDOS:23
-command = taldir-validate-test.sh
+command = taldir-validate-test
 
 [taldir-twitter]
 challenge_fee = KUDOS:2

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]