binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.16k stars 711 forks source link

Return rate limits when limited #1173

Open ThisIsMissEm opened 1 month ago

ThisIsMissEm commented 1 month ago

:bulb: Idea

Currently when ntfy rate limits a client, it seems to just send the 429 status code back, but doesn't advise as to when the rate limit would be lifted. This means that clients can't dynamically pause sending notifications until the rate limit resets, which leads to IP bans.

There is a standards track IETF proposal for RateLimit headers, which could make sense to use: https://www.ietf.org/archive/id/draft-ietf-httpapi-ratelimit-headers-07.html

This currently affects Mastodon: https://github.com/mastodon/mastodon/issues/26078

By advertising when the rate limits reset, we could delay all other notification until after the rate limit resets. I tried to look at both the documentation and code to see if you currently have any code that advertises to the client information about the rate limit, and couldn't find any.

:computer: Target components

ThisIsMissEm commented 15 hours ago

You could also use the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After