containrrr / shoutrrr

Notification library for gophers and their furry friends.
https://containrrr.dev/shoutrrr/
MIT License
975 stars 60 forks source link

Cannot send notifications through matrix #415

Open monkeyfella opened 10 months ago

monkeyfella commented 10 months ago

Running watchtower, and have tried by sending notifications with the 0.8 version as well.

I have joined a room on the matrix server, because I could not get the bot to join a room it was invited to.

In watchtower I try to send with this url:
WATCHTOWER_NOTIFICATION_URL: "matrix://shoutrrr:redacted@matrix.domain.com"

I get:

level=error msg="Failed to send shoutrrr notification" error="1 error(s) sending message, with initial error: failed to send message to room '!DSfY3QSFnozlLb7Qhu:domain.com': M_UNRECOGNIZED: Unrecognized request" index=0 notify=no service=matrix

And on the matrix server the logs show:

2023-11-21T07:01:40.011417Z  WARN conduit: Not found: 
/_matrix/client/r0/rooms/%21DSfY3QSFnozlLb7Qhu:domain.com/send/m.room.message?access_token=<REDACTED>
2023-11-21T07:02:22.868338Z  WARN conduit: Not found: /_matrix/client/r0/rooms/

When trying to send with

./shoutrrr send -u matrix://shoutrrr:password@matrix.domain.com -m test

Logs show:

1 error(s) sending message, with initial error: failed to send message to room '!DSfY3QSFnozlLb7Qhu:domain.com': M_UNRECOGNIZED: Unrecognized request

and the logs on the matrix server shows:

2023-11-21T07:07:53.824758Z  WARN conduit: Not found: /_matrix/client/r0/rooms/%21DSfY3QSFnozlLb7Qhu:domain.com/send/m.room.message?access_token=<REDACTED>

I've redacted the real domain name

piksel commented 10 months ago

HellO!

Do you know what software the matrix server is using, and what version? Synapse maybe? Also, was this a mistake during redaction:

/_matrix/client/r0/rooms/%21DSfY3QSFnozlLb7Qhu:domain.com/send/

(and not matrix.domain.com)?

Trying to rule out some red herrings...

Also, could you post the output of:

curl https://matrix.domain.com/_matrix/client/versions 

Perhaps the services just uses a too old API version?

monkeyfella commented 10 months ago

Hey :)

No, I am using delegation so the domain of the server is domain.com, but it uses the .well-known/matrix/serverredirection to the domain actually running the server which is matrix.domain.com.

I am running the Conduit matrix server.(https://conduit.rs) version 0.6

I have tried with synapse and dendrite before, I was never able to get the bot to actually join the room (tried all sorts of variants of formatting) , I had to join it manually and then remove the room id/alias from the url to be able to send notifications through it.

Edit: output of curl {"versions":["r0.5.0","r0.6.0","v1.1","v1.2","v1.3","v1.4"],"unstable_features":{"org.matrix.e2e_cross_signing":true}}

piksel commented 10 months ago

Hm, it looks like there is a missing txnId in the URL. It's present in the v0.0.0 of the matrix server/client API spec, so I'm not sure why were not adding that. We should probably add support for newer versions as well.

Ref: https://spec.matrix.org/legacy/r0.0.0/client_server.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid

monkeyfella commented 10 months ago

Tried the fix just now, and got it working. Can send message with no room specified (sending to the already joined room) and to specified room with !roomID, and the bot joined the room and everything. Thanks for dealing with this quickly, 👍