Implement Geohash Presence (Heartbeats) (#576)

* geohash announce

* only for some geohashes

* global presence right away

* jitter delays

* show ? people for high-precision geohashes

* 1000 events
This commit is contained in:
callebtc
2026-01-13 03:23:53 +07:00
committed by GitHub
parent 654d385b6d
commit d164b3f9bc
7 changed files with 229 additions and 13 deletions
@@ -117,6 +117,28 @@ object NostrProtocol {
return@withContext senderIdentity.signEvent(event)
}
/**
* Create a geohash-scoped presence event (kind 20001)
* Has no content and no nickname, used for participant counting
*/
suspend fun createGeohashPresenceEvent(
geohash: String,
senderIdentity: NostrIdentity
): NostrEvent = withContext(Dispatchers.Default) {
val tags = mutableListOf<List<String>>()
tags.add(listOf("g", geohash))
val event = NostrEvent(
pubkey = senderIdentity.publicKeyHex,
createdAt = (System.currentTimeMillis() / 1000).toInt(),
kind = NostrKind.GEOHASH_PRESENCE,
tags = tags,
content = ""
)
return@withContext senderIdentity.signEvent(event)
}
/**
* Create a geohash-scoped ephemeral public message (kind 20000)