Skip to content

Commit

Permalink
refactore request function
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Dec 19, 2023
1 parent 4cfb4c8 commit 5eaaa4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions ocrd_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ webhook_send() {
esac

if test -n "$WEBHOOK_RECEIVER_URL" -a -n "$WEBHOOK_KEY_DATA" -a -n "$EVENT"; then
echo "{ \"key-data\": \"$WEBHOOK_KEY_DATA\", \"event\": \"$EVENT\", \"message\": \"$MESSAGE\" }" | curl -k -X POST -H "Content-Type: application/json" -d @- $WEBHOOK_RECEIVER_URL

webhook_request "$WEBHOOK_RECEIVER_URL" "$WEBHOOK_KEY_DATA" "$EVENT" "$MESSAGE"
if ((JOBCOMPLETE)); then
logret # communicate retval 0
fi
Expand All @@ -287,6 +286,10 @@ webhook_send() {
fi
}

webhook_request() {
echo "{ \"key-data\": \"${2}\", \"event\": \"${3}\", \"message\": \"${4}\" }" | curl -k -X POST -H "Content-Type: application/json" -d @- ${1}
}

webhook_send_info() {
if test -n "${1}"; then
webhook_send 1 "${1}"
Expand Down
1 change: 0 additions & 1 deletion tests/ocrd_lib_webhook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ def validateJSON(jsonStr: str) -> Any:
return json.loads(jsonStr)
except ValueError:
assert False, f"The json set to the receiver is not valid."

0 comments on commit 5eaaa4b

Please sign in to comment.