challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit 02f6614010a4e22fddad0ef774564e6b8572a11a
parent 3772a01601e20c0800db9aa0808f3dc115c94856
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 23 Apr 2025 20:36:04 +0200

try to improve challenger pingen error handling

Diffstat:
Msrc/challenger/challenger-send-post.sh | 30++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/challenger/challenger-send-post.sh b/src/challenger/challenger-send-post.sh @@ -23,7 +23,8 @@ then fi ENDPOINT="https://api.pingen.com" -LOGS="$PWD/authorization-post.log" +LOGS="$HOME/authorization-post.log" +ERRORS="$HOME/authorization-post.err" MESSAGE=$(cat -) ADDR="$1" @@ -838,10 +839,27 @@ ATTRS=$(echo "$REPLY" | jq .data.attributes) UPLOAD_URL=$(echo "$ATTRS" | jq -r .url) URL_SIG=$(echo "$ATTRS" | jq -r .url_signature) -curl -s \ +STATUS=$(curl -s \ -X PUT \ -T input.pdf \ - "$UPLOAD_URL" + "$UPLOAD_URL" \ + -o "$MYDIR/upload-status.txt" \ + -w "%{http_code}" -s) + +case "$STATUS" in + 200) + ;; + 201) + ;; + 204) + ;; + *) + echo "Failed to upload letter: $STATUS" >> "$ERRORS" + cat "$MYDIR/upload-status.txt" >> "$ERRORS" + exit 1; + ;; +esac + REQUEST="$(jq -n ' { data: { @@ -869,13 +887,13 @@ STATUS=$(curl -s \ -d "$REQUEST" \ -o "$MYDIR/final-reply.txt" \ -w "%{http_code}" -s) -cat "$MYDIR/final-reply.txt" >> "$LOGS" case "$STATUS" in 201) + cat "$MYDIR/final-reply.txt" >> "$LOGS" ;; *) - echo "Failed to add letter: $STATUS" >> "$LOGS" - echo "$REPLY" + echo "Failed to add letter: $STATUS" >> "$ERRORS" + cat "$MYDIR/final-reply.txt" >> "$ERRORS" exit 1; ;; esac