matrix-notifier: add markdown rendering w/ pandoc
This commit is contained in:
parent
75d482cd6b
commit
758e4599ed
|
@ -99,6 +99,7 @@
|
||||||
wrapperPath = with pkgs; lib.makeBinPath [
|
wrapperPath = with pkgs; lib.makeBinPath [
|
||||||
curl
|
curl
|
||||||
jq
|
jq
|
||||||
|
pandoc
|
||||||
];
|
];
|
||||||
|
|
||||||
fixupPhase = ''
|
fixupPhase = ''
|
||||||
|
|
|
@ -71,6 +71,15 @@ get_message_type() {
|
||||||
printf '%s' "m.$MSG_TYPE"
|
printf '%s' "m.$MSG_TYPE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_message_json() {
|
||||||
|
jq -s '.[0] * .[1]' \
|
||||||
|
<(printf '%s' "$1" |
|
||||||
|
pandoc |
|
||||||
|
jq --raw-input --slurp "{format: \"org.matrix.custom.html\", formatted_body: .}") \
|
||||||
|
<(printf '%s' "$1" |
|
||||||
|
jq --raw-input --slurp "{msgtype: \"$(get_message_type)\", body: .}")
|
||||||
|
}
|
||||||
|
|
||||||
send_message() {
|
send_message() {
|
||||||
local login_json
|
local login_json
|
||||||
local token
|
local token
|
||||||
|
@ -94,8 +103,7 @@ send_message() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
message_json="$(printf '%s' "$MESSAGE" |
|
message_json="$(make_message_json "$MESSAGE")"
|
||||||
jq --raw-input --slurp "{msgtype: \"$(get_message_type)\", body: .}")"
|
|
||||||
curl -XPOST \
|
curl -XPOST \
|
||||||
-d "$message_json" \
|
-d "$message_json" \
|
||||||
"$ADDRESS/_matrix/client/r0/rooms/$(rawurlencode "$ROOM")/send/m.room.message?access_token=$(rawurlencode "$token")" 2>/dev/null
|
"$ADDRESS/_matrix/client/r0/rooms/$(rawurlencode "$ROOM")/send/m.room.message?access_token=$(rawurlencode "$token")" 2>/dev/null
|
||||||
|
|
Loading…
Reference in a new issue