Browse Source

Added some logging

master
Drew Short 4 years ago
parent
commit
ff5a3dc2a3
  1. 12
      bin/out

12
bin/out

@ -3,7 +3,6 @@
# Send message to a matrix room. API call looks like this:
# curl -XPOST -d '{"msgtype":"m.text", "body":"hello"}' "http://matrix.org/_matrix/client/api/v1/rooms/%21CvcvRuDYDzTOzfKKgh%3Alocalhost/send/m.room.message?access_token=YOUR_ACCESS_TOKEN"
set -e
# workaround for directory not existing before get in 3.0.0
mkdir -p "${1}"
@ -19,6 +18,8 @@ payload=$(mktemp /tmp/resource-in.XXXXXX)
cat > "${payload}" <&0
echo "Matrix-Notification-Resource Version: 1.0.0"
matrix_server_url="$(jq -r '.source.matrix_server_url' < "${payload}")"
token="$(jq -r '.source.token' < "${payload}")"
room_id="$(jq -r '.source.room_id' < "${payload}")"
@ -71,13 +72,13 @@ then
[ -n "${formatted_body}" ] && formatted_body="${prefix}: ${formatted_body}"
fi
text=$(echo -n "${text}" | jq -R -s .)
[ -n "${formatted_body}" ] && formatted_body=$(echo -n "${formatted_body}" | jq -R -s .)
if [[ "${is_html}" == "true" ]]; then
if [[ "${is_html}" == "true" && -n "${formatted_body}" ]]; then
formatted_body="${text}"
fi
text=$(echo -n "${text}" | jq -R -s .)
[ -n "${formatted_body}" ] && formatted_body=$(echo -n "${formatted_body}" | jq -R -s .)
[[ "${token}" != "null" ]] && username=$(echo "$token" | envsubst | jq -R -s .)
[[ "${room_id}" != "null" ]] && room_id=$(echo "$room_id" | envsubst | jq -R -s .)
body="$(cat <<EOF
@ -111,7 +112,6 @@ EOF
if [ -n "${trigger}" ]; then
body=$(echo -n "$body" | jq -c ".trigger=\"${trigger}\"")
fi
# fi
compact_body=$(echo -n "${body}" | jq -c '.')

Loading…
Cancel
Save