diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt index 62dfa359d..c64f4005a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt @@ -204,16 +204,17 @@ class EventNotificationConsumer( return } - // The referenced event's author is who the user will see in the final - // notification ("Alice zapped you"). The WakeUp's own pubKey is typically - // a push bot and not useful. Fall back to it only when the `e` tag omits - // the author hint. + // Per spec, p-tags on a WakeUp are the authors of the referenced + // events; those are whose metadata we need to render the notification. + // Fall back to e-tag author hints and finally to the WakeUp signer. val referencedNotes = referencedTags.map { LocalCache.getOrCreateNote(it.eventId) } - val authorCandidates = - referencedTags - .mapNotNull { it.author } + val authorKeys = + (event.authorKeys() + referencedTags.mapNotNull { it.author }) .distinct() .ifEmpty { listOf(event.pubKey) } + val authorCandidates = + authorKeys + .take(MAX_WAKEUP_REFS) .map { LocalCache.getOrCreateUser(it) } coroutineScope { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/notifications/wake/WakeUpEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/notifications/wake/WakeUpEvent.kt index 925efbf85..5fc6ee712 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/notifications/wake/WakeUpEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/notifications/wake/WakeUpEvent.kt @@ -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.taggedUsers +import com.vitorpamplona.quartz.nip01Core.tags.people.toPTag import com.vitorpamplona.quartz.nip31Alts.alt import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.serialization.json.JsonNull.content @@ -68,10 +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]. + // p-tags on a WakeUp identify the AUTHORS of the referenced events — + // the people whose events are the subject of the wake-up and who should + // come online to handle new activity on them. Callers can add extra + // e/p tags via [initializer] when waking up about multiple events. fun build( about: EventHintBundle, createdAt: Long = TimeUtils.now(), @@ -79,7 +79,7 @@ class WakeUpEvent( ) = eventTemplate(KIND, content, createdAt) { alt(ALT_DESCRIPTION) about(about) - notify(about.event.tags.taggedUsers()) + notify(about.toPTag()) kind(about.event.kind) initializer() }