From 0b52dd50b64a41f5fad10e6a9bd2cd652619939d Mon Sep 17 00:00:00 2001 From: Alireza <5110480+silverbios@users.noreply.github.com> Date: Sat, 10 Feb 2024 03:03:07 +0330 Subject: [PATCH] Create notify_matrix.sh add notification template for matrix-synapse --- notify_matrix.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 notify_matrix.sh diff --git a/notify_matrix.sh b/notify_matrix.sh new file mode 100644 index 0000000..5f76a32 --- /dev/null +++ b/notify_matrix.sh @@ -0,0 +1,28 @@ +### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +# +# Copy/rename this file to notify.sh to enable the notification snippet. +# Required receiving services must already be set up. +# Modify to fit your setup - set MatrixServer, Room_id and AccessToken and . + +send_notification() { + Updates=("$@") + UpdToString=$( printf "%s\n" "${Updates[@]}" ) + FromHost=$(hostname) + + # platform specific notification code would go here + printf "\nSending Matrix notification\n" + + # Setting the MessageBody variable here. + MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString" + + # Modify to fit your setup: + AccessToken="Your Matrix token here" + Room_id="Enter Room_id here" + MatrixServer="Enter Your HomeServer URL" + MsgBody="{msgtype":"m.text","body":"$MessageBody"}" + + # URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message/?access_token=xxxxxxxx + + curl -sS -o /dev/null --fail -X PUT "$MatrixServer/_matrix/client/r0/rooms/$Room_id/send/m.room.message/?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody" + +}