Browse Source

Apparently formatted_text is only rendered on m.notice or m.text msgtypes. Fix the parsing on the formatted/linked text, and add a plain-text version for other msgtypes.

master
John Locke 8 years ago
parent
commit
fa9f556051
  1. 15
      bin/out

15
bin/out

@ -55,14 +55,17 @@ then
text="$(eval printf ${text} )" text="$(eval printf ${text} )"
[[ -z "${text}" ]] && text="_(missing notification text)_" [[ -z "${text}" ]] && text="_(missing notification text)_"
text="$(echo -n "${text}" | jq -R -s .)"
[ "${link}" == "true" ] && text="<a href=\"$ATC_EXTERNAL_URL/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME\">${text}</a>"
[ "${link}" == "true" ] && formatted_body="<a href=\"$ATC_EXTERNAL_URL/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME\">${text}</a>"
if [ -n "$prefix" ]; then if [ -n "$prefix" ]; then
prefix="$(eval printf ${prefix} )" prefix="$(eval printf ${prefix} )"
text="${prefix}: ${text}" text="${prefix}: ${text}"
[ -n "${formatted_body}" ] && formatted_body="${prefix}: ${formatted_body}"
fi fi
text="$(echo -n "${text}" | jq -R -s .)"
[ -n "${formatted_body}" ] && formatted_body="$(echo -n "${formatted_body}" | jq -R -s .)"
[[ "${token}" != "null" ]] && username="$(eval "printf ${token}" | jq -R -s .)" [[ "${token}" != "null" ]] && username="$(eval "printf ${token}" | jq -R -s .)"
[[ "${room_id}" != "null" ]] && room_id="$(eval "printf ${room_id}" | jq -R -s .)" [[ "${room_id}" != "null" ]] && room_id="$(eval "printf ${room_id}" | jq -R -s .)"
body="$(cat <<EOF body="$(cat <<EOF
@ -72,7 +75,7 @@ then
} }
EOF EOF
)" )"
if [ "${msgtype}" != "m.notice" ]; then
# if [ "${msgtype}" != "m.notice" ]; then
# we can attach custom data... # we can attach custom data...
builddata="$(cat <<EOF builddata="$(cat <<EOF
{ {
@ -85,13 +88,17 @@ EOF
EOF EOF
)" )"
body=$(echo -n $body | jq -c ".build=$builddata") body=$(echo -n $body | jq -c ".build=$builddata")
if [ -n "${formatted_body}" ]; then
body=$(echo -n $body | jq -c ".formatted_body=$formatted_body")
body=$(echo -n $body | jq -c ".format=\"org.matrix.custom.html\"")
fi
if [ -n "$DATA_FILE_CONTENT" ]; then if [ -n "$DATA_FILE_CONTENT" ]; then
body=$(echo -n $body | jq -c ".data=$DATA_FILE_CONTENT") body=$(echo -n $body | jq -c ".data=$DATA_FILE_CONTENT")
fi fi
if [ -n "${trigger}" ]; then if [ -n "${trigger}" ]; then
body=$(echo -n $body | jq -c ".trigger=\"${trigger}\"") body=$(echo -n $body | jq -c ".trigger=\"${trigger}\"")
fi fi
fi
# fi
compact_body="$(echo -n "${body}" | jq -c '.')" compact_body="$(echo -n "${body}" | jq -c '.')"

Loading…
Cancel
Save