-
-
Notifications
You must be signed in to change notification settings - Fork 773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider Including a Matrix Gateway endpoint as part of ntfy #319
Comments
For information, that's the functions that does it for NextPush : |
Sooo... I can see why this is awkward. You're asking me to put more load on the ntfy.sh server to support an unrelated feature, and introduce a potential security issue by letting the ntfy server make HTTP requests to arbitrary servers (see #93). I am sympathetic to the cause, yet you have to understand my hesitation. ntfy is a pubsub system primarily for push notifications from scripts and such. It's not a Matrix chat relay/gateway or anything Matrix specific. |
I understand your hesitation since it is not directly related to the core of the project :) Just to make it clear: For instance, the following request would do the same thing than posting it to https://ntfy.sh/exampleTopicID?up=1
Once again, I understand if you do not want to implement it. [1] Which would be totally unrelated to this project ^^ |
Ohhh I see. Yeah I can totally do that. |
Thanks @p1gp1g for clarifying. Also, while it would be nice to have it on the public ntfy.sh instance, I think it brings more value for self-hosted instances, as users don't have to fiddle with setting up a gateway or rewrite proxy themselves, which they can get wrong. |
I thought this was a fun 30min thing to do and here's the result: #326 This implementation is incomplete and has issues:
|
I thought it too, but it might take more time depending on the internal architecture :/
Without the response Also, without the discovery response (bellow), clients won't know there is a gateway and won't use it.
It seems all homeservers send only one device at this moment. I don't know if any plan to change this behavior
|
Hey, I was not expecting you to have a look at it so soon. Thanks a lot! Here are my two cents (mostly the same as @p1gp1g's message):
|
I think I can do the response bit, as long as I don't have to implement 1-to-N I'm okay with the hacks. Just thought I'd ask if that's okay before proceeding. |
Right now, I'd say the discovery response + the |
I forgot the GET but that'll be easy. It's still ugly but here's the behavior: Entirely invalid request
Log:
Valid request:
Log:
Valid Matrix message, but with invalid push key
Log:
|
Wow, the PR grew more than I expected. It looks like it touches quite a bit of core code, as in: it is not self-contained. I hope you're okay with this, I wouldn't want to increase the maintenance burden, especially for a feature that might get deprecated in 1-2 years. Otherwise, the API and feature set looks perfect to me! I'll test it ASAP, thanks a lot! |
I don't think it will be deprecated in 1-2 years. The MSC is probably far for being accepted, and IIRC, this MSC alone is not enough to get rid of matrix gateway :)
|
Valid
Log:
Invalid
Log:
Total garbage
Log:
|
Feel free to review #326. I'm alright with it, though I'll add some more docs. |
This is live https://ntfy.sh/docs/releases/#ntfy-server-v1260 |
I upgraded my own server, it works perfectly 🎉 Thank you again! |
Hi! |
You have one here : https://spec.matrix.org/v1.9/push-gateway-api/ |
Thanks @p1gp1g! So, the JSON seems to be accepted, but then the notification somehow does not get to my phone. ntfy | 2024/01/16 12:41:55 DEBUG Received message (http_method=POST, http_path=/up123456, message_body_size=729, message_call=, message_delayed=false, message_email=, message_event=message, message_firebase=true, message_id=zjXnrADqSNCX, message_sender=ipv6, message_time=1705408915, message_unifiedpush=false, tag=publish, topic=up123456, topic_last_access=2024-01-16T12:41:52.391Z, topic_subscribers=1, visitor_auth_limiter_limit=0.016666666666666666, visitor_auth_limiter_tokens=30, visitor_id=ip:ipv6, visitor_ip=ipv6, visitor_messages=15, visitor_messages_limit=17280, visitor_messages_remaining=17265, visitor_request_limiter_limit=0.2, visitor_request_limiter_tokens=58.6226667566, visitor_seen=2024-01-16T12:41:55.501Z) As far as I understand, this should be the contrary? I'll recheck documentation and my setup (pretty sure I did everything right). I was worried that my haproxy configuration was not correct but apparently this is something else. Anyway, thanks again for your help and sorry to pollute an old issue that has probably nothing to do with my problem (I'll reach on matrix ntfy or unifiedpush channel). |
Hello, this is kind of awkward to ask as the use-case is quite specific, but at the same time it should be fairly self-contained.
Rationale
The core issue is using UnifiedPush in conjunction with a Matrix Client and Server. The Matrix Client will pass a push URL to the Matrix server. However, the Matrix spec mandates some endpoints for push servers: https://spec.matrix.org/v1.2/push-gateway-api/
Basically, the spec mandates the use of the
/_matrix/push/v1/notify
path.Therefore, one has to use an intermediate gateway before forwarding requests to ntfy. When users do not use their own, clients use default ones, which led to rate-limiting: #144
Benefit to users
Currently, users can host a gateway themselves through the common-proxies project, or some other rewrite proxy.
That's one more step for users, who might feel discouraged from doing so.
Including that gateway would increase privacy, for users of the public ntfy instance, but even more so for users who host their own homeserver and ntfy instance, as push messages do not need to travel through third-party gateways.
Needed changes
The set of features to support is relatively simple:
GET /_matrix/push/v1/notify
json_body["notification"]["devices"][0]["pushkey"]
. In this case,exampleTopicID?up=1
.That's all. This should only be necessary until the Matrix Spec Change 2970 lands to delete that requirement and allow arbitrary paths, so that's your call.
Impact assessment
One more thing to expect: on the public ntfy instance, FluffyChat's and schildichat's public gateways wouldn't be used anymore, so individual Matrix servers would be subjected to rate-limiting instead, probably Matrix.org, kde.org and mozilla.org, as they are the biggest I can think of right now.
On the other hand, it makes it easier to single out abusive Matrix homeservers without locking users out. Moreover, as more clients appear (Element will soon support UP), more gateways will appear.
It might also make it easier to rate-limit matrix separately while the MSC isn't merged.
The text was updated successfully, but these errors were encountered: