Adding a geohash mipmap to events.

This commit is contained in:
Vitor Pamplona 2023-11-22 12:48:19 -05:00
parent d1bef11f88
commit 0de4cd5c18
6 changed files with 12 additions and 6 deletions

View File

@ -62,7 +62,7 @@ class ChannelMessageEvent(
tags.add(listOf("zapraiser", "$it"))
}
geohash?.let {
tags.add(listOf("g", it))
tags.addAll(geohashMipMap(it))
}
signer.sign(createdAt, kind, tags, content, onReady)

View File

@ -84,7 +84,7 @@ class ChatMessageEvent(
tags.add(listOf("zapraiser", "$it"))
}
geohash?.let {
tags.add(listOf("g", it))
tags.addAll(geohashMipMap(it))
}
subject?.let {
tags.add(listOf("subject", it))

View File

@ -78,7 +78,7 @@ class LiveActivitiesChatMessageEvent(
tags.add(listOf("zapraiser", "$it"))
}
geohash?.let {
tags.add(listOf("g", it))
tags.addAll(geohashMipMap(it))
}
signer.sign(createdAt, kind, tags, content, onReady)

View File

@ -97,7 +97,7 @@ class PollNoteEvent(
tags.add(listOf("zapraiser", "$it"))
}
geohash?.let {
tags.add(listOf("g", it))
tags.addAll(geohashMipMap(it))
}
signer.sign(createdAt, kind, tags, msg, onReady)

View File

@ -129,7 +129,7 @@ class PrivateDmEvent(
tags.add(listOf("zapraiser", "$it"))
}
geohash?.let {
tags.add(listOf("g", it))
tags.addAll(geohashMipMap(it))
}
signer.nip04Encrypt(message, recipientPubKey) { content ->
@ -138,3 +138,9 @@ class PrivateDmEvent(
}
}
}
fun geohashMipMap(geohash: String): List<List<String>> {
return geohash.indices.asSequence().map {
listOf("g", geohash.substring(0, it+1))
}.toList().reversed()
}

View File

@ -94,7 +94,7 @@ class TextNoteEvent(
tags.add(listOf("zapraiser", "$it"))
}
geohash?.let {
tags.add(listOf("g", it))
tags.addAll(geohashMipMap(it))
}
signer.sign(createdAt, kind, tags, msg, onReady)