Skip to content

Commit

Permalink
Add parsing of message from markdown to html...
Browse files Browse the repository at this point in the history
... and remove formatted_message
  • Loading branch information
s3krit committed Mar 2, 2020
1 parent ecd689b commit 35a9664
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM parity/tools:latest
RUN apk add markdown
COPY entrypoint.sh /
CMD chmod +x /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ inputs:
description: "Message to send in plaintext format"
default: ""
required: true
formatted_message:
description: "Message to send, formatted in Matrix HTML"
default: ""
required: false
runs:
using: docker
image: 'Dockerfile'
Expand Down
9 changes: 3 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

# structure_message $content $formatted_content (optional)
structure_message() {
if [ -z "$2" ]; then
body=$(jq -Rs --arg body "$1" '{"msgtype": "m.text", $body}' < /dev/null)
else
body=$(jq -Rs --arg body "$1" --arg formatted_body "$2" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
fi
parsed="$(echo "$1" | markdown)"
body=$(jq -Rs --arg body "$1" --arg formatted_body "$parsed" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
echo "$body"
}

Expand All @@ -22,4 +19,4 @@ send_message() {
fi
}

send_message "$(structure_message "$INPUT_MESSAGE" "$INPUT_FORMATTED_MESSAGE")" "$INPUT_ROOM_ID" "$INPUT_ACCESS_TOKEN"
send_message "$(structure_message "$INPUT_MESSAGE")" "$INPUT_ROOM_ID" "$INPUT_ACCESS_TOKEN"

0 comments on commit 35a9664

Please sign in to comment.