feat: Follow-gated push notifications and NIP-01 replaceable event fixes #103
Open
Maphikza wants to merge 3 commits intoHORNET-Storage:mainfrom
Open
feat: Follow-gated push notifications and NIP-01 replaceable event fixes #103Maphikza wants to merge 3 commits intoHORNET-Storage:mainfrom
Maphikza wants to merge 3 commits intoHORNET-Storage:mainfrom
Conversation
Only send push notifications to users from authors they follow. Includes proactive cache warming from incoming kind 3 events, bounded cache with oldest-10% eviction, and configurable TTL. Kind 1059 (DMs) and test notifications are exempt from gating. Users without a local contact list receive all notifications.
… 3 handlers Kind 0 (profile) and kind 3 (contact list) handlers were blindly deleting existing events without checking timestamps, allowing older events to overwrite newer ones. Now both handlers compare CreatedAt timestamps and reject incoming events that are older than what's already stored. Also hardens the follow cache warming in push service to check the store for a newer kind 3 before warming, preventing stale contact lists from polluting the cache.
With low traffic, all notifications should reach users to keep the app feeling active. When traffic grows and spam becomes a concern, operators can enable follow-gating by setting follow_gated: true in config.yaml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds follow-gated push notifications with a lazy TTL-based cache, fixes replaceable event handling in kind 0 and kind 3 handlers, and includes several push notification improvements.
Push Notification Enhancements
services/push/service.go): Recipients can be filtered so they only receive notifications from authors they follow. Uses a lazy in-memory cache with TTL expiry and bounded eviction — no external dependencies, no polling loops. The cache warms proactively when kind 3 (contact list) events arrive viaProcessEvent, and falls back to a store query on cache miss.shouldNotify).84731d2): Push notification payloads now include context about the referenced event (e.g., the original note content when someone reacts to your post).NIP-01 Replaceable Event Fixes
CreatedAttimestamp). Previously, older events could silently overwrite newer ones.warmFollowCacheFromEvent): Before warming the follow cache from an incoming kind 3 event, the push service checks the store to ensure it's not overwriting the cache with stale data.Configuration
Three new fields under
push_notifications.serviceinconfig.yaml: