~vpzom/shoved-matrix

ebaad5b73ae780a07e823ab2b429dbc3f8625aab — Colin Reeder 8 months ago ede5219
Make it work
2 files changed, 11 insertions(+), 1 deletions(-)

M handle.sh
M register.sh
M handle.sh => handle.sh +8 -1
@@ 2,4 2,11 @@

body="$(tee)"
echo "$body"
notify-send "something!"

room_id="$(echo "$body" | jq -r .room_id)"
event_id="$(echo "$body" | jq -r .event_id)"
homeserver_url="$(jq -r .homeserver_url < ~/.config/shoved-matrix/auth.json)"
token="$(jq -r .token < ~/.config/shoved-matrix/auth.json)"

event="$(curl -s -H "Authorization: Bearer $token" "$homeserver_url"/_matrix/client/v3/rooms/$room_id/event/$event_id)"
notify-send "$(echo "$event" | jq -r .sender)" "$(echo "$event" | jq -r .content.body)"

M register.sh => register.sh +3 -0
@@ 15,5 15,8 @@ echo "endpoint = $endpoint"
echo "p256dh = $p256dh"
echo "auth = $auth"

mkdir -p ~/.config/shoved-matrix
echo '{"homeserver_url": '"$(echo "$homeserver" | jq -R)"', "token": '"$(echo "$token" | jq -R)"'}' > ~/.config/shoved-matrix/auth.json

curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" "$homeserver"/_matrix/client/v3/pushers/set -d \
	'{"app_id": "click.vpzom.shoved-matrix", "data": {"format": "event_id_only", "url": "https://push.chat.vpzom.click/_matrix/push/v1/notify", "endpoint": '"$endpoint"', "auth": '"$auth"'}, "kind": "http", "pushkey": '"$p256dh"', "app_display_name": "shoved-matrix", "device_display_name": '"$(hostname | jq -R)"', "lang": "en"}'