fix: make WakeUp events actually deliver notifications

The WakeUp notification path had three latent bugs that caused pushed
WakeUps to silently not deliver anything to the user:

- WakeUpEvent.build() tagged the about event's AUTHOR as the recipient
  (via EventHintBundle.toPTag()), so a WakeUp about a zap from Alice to
  Bob would p-tag Alice. The consumer matches recipients by p-tag, so
  Bob — the intended recipient — was filtered out. Forward the about
  event's audience (its own p-tags) instead.

- wakeUpFor() passed the WakeUp's own note to EventFinderQueryState. The
  finder's filterMissingEvents only queries for the note itself (already
  in cache) or its replyTo (empty because computeReplyTo had no WakeUp
  case). The referenced events were never REQ'd on relays. Link the
  referenced events via computeReplyTo and subscribe the finder on each
  referenced note directly so filterMissingEvents picks them up.

- UserFinder was subscribed against the WakeUp's own pubKey (typically a
  push bot), not the author of the event the notification is about.
  Pull author pubkeys from the e-tag author hint, falling back to the
  WakeUp signer only when the hint is absent.

Also: bound e-tag count per WakeUp to 16 to prevent subscription
flooding, log the 30s timeout, extract WAKEUP_WINDOW_MS constant, drop
the now-unused Note parameter from wakeUpFor.
This commit is contained in:
Claude
2026-04-24 01:26:50 +00:00
parent 81819b6fbe
commit 3c6b2bec9f
3 changed files with 66 additions and 17 deletions
@@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.kinds.kind
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag.Companion.parse
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag.Companion.parseKey
import com.vitorpamplona.quartz.nip01Core.tags.people.toPTag
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
import com.vitorpamplona.quartz.nip31Alts.alt
import com.vitorpamplona.quartz.utils.TimeUtils
import kotlinx.serialization.json.JsonNull.content
@@ -68,6 +68,10 @@ class WakeUpEvent(
const val KIND = 23903
const val ALT_DESCRIPTION = "WakeUp"
// Tags the audience of [about] (its `p` tags) as the recipients to wake up.
// The about event's author is NOT tagged: a WakeUp about a zap from Alice
// to Bob should notify Bob, not Alice. Callers can add more recipients via
// [initializer].
fun build(
about: EventHintBundle<Event>,
createdAt: Long = TimeUtils.now(),
@@ -75,7 +79,7 @@ class WakeUpEvent(
) = eventTemplate(KIND, content, createdAt) {
alt(ALT_DESCRIPTION)
about(about)
notify(about.toPTag())
notify(about.event.tags.taggedUsers())
kind(about.event.kind)
initializer()
}