[PR #609] [CLOSED] Subscriber Billed Topics #1348

Closed
opened 2026-05-07 01:01:42 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/609
Author: @karmanyaahm
Created: 2/14/2023
Status: Closed

Base: mainHead: user-account


📝 Commits (10+)

  • d686e1e Use visitor instead of UserID in topicSubscription
  • 28b654a Keep track of lastVisitor to a topic
  • fb2fa4c Fix m.Expires and prune stale topics based on lastVisitorExpires
  • 6bfe4a9 Bill to visitor and set TTL in response
  • 7c5b9c0 only log expiry if applicable
  • c6b64df remove ttl
  • b9badee remove TTL, will make a seperate PR
  • 36685e9 Suggested changes
  • 1655f58 rate limiting impl 2.0?
  • bc3d897 Use mutexes in topic

📊 Changes

5 files changed (+172 additions, -64 deletions)

View changed files

📝 server/errors.go (+2 -1)
📝 server/server.go (+63 -46)
📝 server/server_middleware.go (+25 -1)
📝 server/topic.go (+61 -14)
📝 server/util.go (+21 -2)

📄 Description

I am going with bill-to-last-visitor-for-12-hrs even though it doesn't allow users to unsubscribe because it is the simplest to explain. It's much easier to document and explain if you subscribe to a up_ topic, you are responsible for whatever is sent there for the next 12 hrs, so keep it secret, than anything else I could come up with.

The only other simple-for-the-user options would be:

  1. You can only subscribe to 30 UP topics in a day. Each UP topic can receive 100 messages / day. However, that requires keeping track of all those states and adds significant complexity to the code.
  2. Bill in sub := func(v *visitor, msg *message) error {, so only messages you actually receive count against you. However, that allows spamming the cache with messages that no one is billed for, on the sending side.

I'll add tests and rebase it and stuff if you're good with this general implementation.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/609 **Author:** [@karmanyaahm](https://github.com/karmanyaahm) **Created:** 2/14/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `user-account` --- ### 📝 Commits (10+) - [`d686e1e`](https://github.com/binwiederhier/ntfy/commit/d686e1ee77b0a1de2ea108a12259eae6497def5c) Use visitor instead of UserID in topicSubscription - [`28b654a`](https://github.com/binwiederhier/ntfy/commit/28b654ae2746b6a48deddab9df69dfc5fa88895e) Keep track of lastVisitor to a topic - [`fb2fa4c`](https://github.com/binwiederhier/ntfy/commit/fb2fa4c478778ab0d09154b5d274ae37caa6a4b6) Fix m.Expires and prune stale topics based on lastVisitorExpires - [`6bfe4a9`](https://github.com/binwiederhier/ntfy/commit/6bfe4a97797bcb3f513f63b5dcc944decb60d926) Bill to visitor and set TTL in response - [`7c5b9c0`](https://github.com/binwiederhier/ntfy/commit/7c5b9c0e62fc1ec113f12b81e70735e4fb84dc1e) only log expiry if applicable - [`c6b64df`](https://github.com/binwiederhier/ntfy/commit/c6b64df662c8ea9a29d44571dcf7acba09cb8b1e) remove ttl - [`b9badee`](https://github.com/binwiederhier/ntfy/commit/b9badee6dbb4d43d6f1abee2f433e7113bb86ab8) remove TTL, will make a seperate PR - [`36685e9`](https://github.com/binwiederhier/ntfy/commit/36685e9df9b9792d85ca7b448ff29a570f6389df) Suggested changes - [`1655f58`](https://github.com/binwiederhier/ntfy/commit/1655f584f9382239ab89f78f3250bc37aa5d62f3) rate limiting impl 2.0? - [`bc3d897`](https://github.com/binwiederhier/ntfy/commit/bc3d897d7a315153f9dcdbf742435551abbeda4e) Use mutexes in topic ### 📊 Changes **5 files changed** (+172 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `server/errors.go` (+2 -1) 📝 `server/server.go` (+63 -46) 📝 `server/server_middleware.go` (+25 -1) 📝 `server/topic.go` (+61 -14) 📝 `server/util.go` (+21 -2) </details> ### 📄 Description I am going with bill-to-last-visitor-for-12-hrs even though it doesn't [allow users to unsubscribe](https://github.com/binwiederhier/ntfy/pull/584#discussion_r1083381767) because it is the simplest to explain. It's much easier to document and explain _if you subscribe to a `up_` topic, you are responsible for whatever is sent there for the next 12 hrs, so keep it secret_, than anything else I could come up with. The only other simple-for-the-user options would be: 1. _You can only subscribe to 30 UP topics in a day. Each UP topic can receive 100 messages / day._ However, that requires keeping track of all those states and adds significant complexity to the code. 2. Bill in `sub := func(v *visitor, msg *message) error {`, so only messages you actually receive count against you. However, that allows spamming the cache with messages that no one is billed for, on the sending side. I'll add tests and rebase it and stuff if you're good with this general implementation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:01:42 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1348
No description provided.