mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-24 11:16:04 +02:00
Generalizes the hashtag and index tag parser for the content as well as the way to pass params to build them on create.
This commit is contained in:
@@ -2275,7 +2275,6 @@ class Account(
|
|||||||
replyTos = repliesToHex,
|
replyTos = repliesToHex,
|
||||||
mentions = mentionsHex,
|
mentions = mentionsHex,
|
||||||
addresses = addresses,
|
addresses = addresses,
|
||||||
extraTags = null,
|
|
||||||
zapReceiver = zapReceiver,
|
zapReceiver = zapReceiver,
|
||||||
markAsSensitive = wantsToMarkAsSensitive,
|
markAsSensitive = wantsToMarkAsSensitive,
|
||||||
zapRaiserAmount = zapRaiserAmount,
|
zapRaiserAmount = zapRaiserAmount,
|
||||||
|
@@ -35,7 +35,7 @@ import com.vitorpamplona.amethyst.model.LocalCache
|
|||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
|
@@ -25,8 +25,10 @@ import com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent
|
|||||||
import com.vitorpamplona.quartz.nip01Core.core.firstTagValue
|
import com.vitorpamplona.quartz.nip01Core.core.firstTagValue
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.buildUrlRefs
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.parse
|
import com.vitorpamplona.quartz.nip19Bech32.parse
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
||||||
@@ -64,14 +66,9 @@ open class InteractiveStoryBaseEvent(
|
|||||||
emojis: List<EmojiUrl>? = null,
|
emojis: List<EmojiUrl>? = null,
|
||||||
): Array<Array<String>> {
|
): Array<Array<String>> {
|
||||||
val tags = mutableListOf<Array<String>>()
|
val tags = mutableListOf<Array<String>>()
|
||||||
findHashtags(content).forEach {
|
|
||||||
val lowercaseTag = it.lowercase()
|
tags.addAll(buildHashtagTags(findHashtags(content)))
|
||||||
tags.add(arrayOf("t", it))
|
tags.addAll(buildUrlRefs(findURLs(content)))
|
||||||
if (it != lowercaseTag) {
|
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
findURLs(content).forEach { tags.add(arrayOf("r", it)) }
|
|
||||||
|
|
||||||
zapReceiver?.forEach {
|
zapReceiver?.forEach {
|
||||||
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
||||||
|
@@ -20,7 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.quartz.nip01Core.tags.geohash
|
package com.vitorpamplona.quartz.nip01Core.tags.geohash
|
||||||
|
|
||||||
fun geohashMipMap(geohash: String): Array<Array<String>> =
|
import com.vitorpamplona.quartz.nip01Core.core.TagArray
|
||||||
|
|
||||||
|
fun geohashMipMap(geohash: String): TagArray =
|
||||||
geohash.indices
|
geohash.indices
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { arrayOf("g", geohash.substring(0, it + 1)) }
|
.map { arrayOf("g", geohash.substring(0, it + 1)) }
|
||||||
|
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2024 Vitor Pamplona
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.vitorpamplona.quartz.nip01Core.tags.hashtags
|
||||||
|
|
||||||
|
fun buildHashtagTags(tags: List<String>): List<Array<String>> {
|
||||||
|
val uniqueTags = mutableSetOf<String>()
|
||||||
|
|
||||||
|
tags.forEach { tag ->
|
||||||
|
uniqueTags.add(tag)
|
||||||
|
val lowercaseTag = tag.lowercase()
|
||||||
|
if (tag != lowercaseTag) {
|
||||||
|
uniqueTags.add(lowercaseTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uniqueTags.map {
|
||||||
|
arrayOf("t", it)
|
||||||
|
}
|
||||||
|
}
|
@@ -20,15 +20,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.quartz.nip10Notes
|
package com.vitorpamplona.quartz.nip10Notes
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.taggedAddresses
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.taggedAddresses
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
|
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findIndexTagsWithEventsOrAddresses
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findIndexTagsWithPeople
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser
|
import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser.nip19regex
|
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress
|
import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NEmbed
|
import com.vitorpamplona.quartz.nip19Bech32.entities.NEmbed
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
||||||
@@ -39,10 +39,6 @@ import com.vitorpamplona.quartz.nip19Bech32.parse
|
|||||||
import com.vitorpamplona.quartz.nip19Bech32.parseAtag
|
import com.vitorpamplona.quartz.nip19Bech32.parseAtag
|
||||||
import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent
|
import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent
|
||||||
import com.vitorpamplona.quartz.nip72ModCommunities.CommunityDefinitionEvent
|
import com.vitorpamplona.quartz.nip72ModCommunities.CommunityDefinitionEvent
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
val tagSearch = Pattern.compile("(?:\\s|\\A)\\#\\[([0-9]+)\\]")
|
|
||||||
val hashtagSearch = Pattern.compile("(?:\\s|\\A)#([^\\s!@#\$%^&*()=+./,\\[{\\]};:'\"?><]+)")
|
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
open class BaseTextNoteEvent(
|
open class BaseTextNoteEvent(
|
||||||
@@ -111,44 +107,19 @@ open class BaseTextNoteEvent(
|
|||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
|
||||||
val matcher = tagSearch.matcher(content)
|
val citedUsers = mutableSetOf<String>()
|
||||||
val returningList = mutableSetOf<String>()
|
|
||||||
while (matcher.find()) {
|
findIndexTagsWithPeople(content, tags, citedUsers)
|
||||||
try {
|
|
||||||
val tag = matcher.group(1)?.let { tags[it.toInt()] }
|
Nip19Parser.parseAll(content).forEach { parsed ->
|
||||||
if (tag != null && tag.size > 1 && tag[0] == "p") {
|
when (parsed) {
|
||||||
returningList.add(tag[1])
|
is NProfile -> citedUsers.add(parsed.hex)
|
||||||
}
|
is NPub -> citedUsers.add(parsed.hex)
|
||||||
} catch (e: Exception) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val matcher2 = nip19regex.matcher(content)
|
citedUsersCache = citedUsers
|
||||||
while (matcher2.find()) {
|
return citedUsers
|
||||||
val type = matcher2.group(2) // npub1
|
|
||||||
val key = matcher2.group(3) // bech32
|
|
||||||
val additionalChars = matcher2.group(4) // additional chars
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (type != null) {
|
|
||||||
val parsed = Nip19Parser.parseComponents(type, key, additionalChars)?.entity
|
|
||||||
|
|
||||||
if (parsed != null) {
|
|
||||||
if (parsed is NProfile) {
|
|
||||||
returningList.add(parsed.hex)
|
|
||||||
}
|
|
||||||
if (parsed is NPub) {
|
|
||||||
returningList.add(parsed.hex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.w("Unable to parse cited users that matched a NIP19 regex", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
citedUsersCache = returningList
|
|
||||||
return returningList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findCitations(): Set<HexKey> {
|
fun findCitations(): Set<HexKey> {
|
||||||
@@ -156,39 +127,16 @@ open class BaseTextNoteEvent(
|
|||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
|
||||||
val citations = mutableSetOf<HexKey>()
|
val citations = mutableSetOf<String>()
|
||||||
// Removes citations from replies:
|
|
||||||
val matcher = tagSearch.matcher(content)
|
|
||||||
while (matcher.find()) {
|
|
||||||
try {
|
|
||||||
val tag = matcher.group(1)?.let { tags[it.toInt()] }
|
|
||||||
if (tag != null && tag.size > 1 && tag[0] == "e") {
|
|
||||||
citations.add(tag[1])
|
|
||||||
}
|
|
||||||
if (tag != null && tag.size > 1 && tag[0] == "a") {
|
|
||||||
citations.add(tag[1])
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val matcher2 = nip19regex.matcher(content)
|
findIndexTagsWithEventsOrAddresses(content, tags, citations).toMutableSet()
|
||||||
while (matcher2.find()) {
|
|
||||||
val type = matcher2.group(2) // npub1
|
|
||||||
val key = matcher2.group(3) // bech32
|
|
||||||
val additionalChars = matcher2.group(4) // additional chars
|
|
||||||
|
|
||||||
if (type != null) {
|
Nip19Parser.parseAll(content).forEach { entity ->
|
||||||
val parsed = Nip19Parser.parseComponents(type, key, additionalChars)?.entity
|
when (entity) {
|
||||||
|
is NEvent -> citations.add(entity.hex)
|
||||||
if (parsed != null) {
|
is NAddress -> citations.add(entity.aTag())
|
||||||
when (parsed) {
|
is Note -> citations.add(entity.hex)
|
||||||
is NEvent -> citations.add(parsed.hex)
|
is NEmbed -> citations.add(entity.event.id)
|
||||||
is NAddress -> citations.add(parsed.aTag())
|
|
||||||
is Note -> citations.add(parsed.hex)
|
|
||||||
is NEmbed -> citations.add(parsed.event.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,18 +175,3 @@ open class BaseTextNoteEvent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findHashtags(content: String): List<String> {
|
|
||||||
val matcher = hashtagSearch.matcher(content)
|
|
||||||
val returningList = mutableSetOf<String>()
|
|
||||||
while (matcher.find()) {
|
|
||||||
try {
|
|
||||||
val tag = matcher.group(1)
|
|
||||||
if (tag != null && tag.isNotBlank()) {
|
|
||||||
returningList.add(tag)
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returningList.toList()
|
|
||||||
}
|
|
||||||
|
@@ -20,12 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.quartz.nip10Notes
|
package com.vitorpamplona.quartz.nip10Notes
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser
|
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.entities.Note
|
|
||||||
import com.vitorpamplona.quartz.utils.bytesUsedInMemory
|
import com.vitorpamplona.quartz.utils.bytesUsedInMemory
|
||||||
import com.vitorpamplona.quartz.utils.pointerSizeInBytes
|
import com.vitorpamplona.quartz.utils.pointerSizeInBytes
|
||||||
import com.vitorpamplona.quartz.utils.removeTrailingNullsAndEmptyOthers
|
import com.vitorpamplona.quartz.utils.removeTrailingNullsAndEmptyOthers
|
||||||
@@ -52,21 +49,4 @@ data class ETag(
|
|||||||
fun toETagArray() = removeTrailingNullsAndEmptyOthers("e", eventId, relay, authorPubKeyHex)
|
fun toETagArray() = removeTrailingNullsAndEmptyOthers("e", eventId, relay, authorPubKeyHex)
|
||||||
|
|
||||||
fun toQTagArray() = removeTrailingNullsAndEmptyOthers("q", eventId, relay, authorPubKeyHex)
|
fun toQTagArray() = removeTrailingNullsAndEmptyOthers("q", eventId, relay, authorPubKeyHex)
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun parseNIP19(nevent: String): ETag? {
|
|
||||||
try {
|
|
||||||
val parsed = Nip19Parser.uriToRoute(nevent)?.entity
|
|
||||||
|
|
||||||
return when (parsed) {
|
|
||||||
is Note -> ETag(parsed.hex)
|
|
||||||
is NEvent -> ETag(parsed.hex, parsed.author, parsed.relay.firstOrNull())
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
Log.w("PTag", "Issue trying to Decode NIP19 $this: ${e.message}")
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -21,14 +21,16 @@
|
|||||||
package com.vitorpamplona.quartz.nip10Notes
|
package com.vitorpamplona.quartz.nip10Notes
|
||||||
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import com.linkedin.urls.detection.UrlDetector
|
|
||||||
import com.linkedin.urls.detection.UrlDetectorOptions
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent
|
import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.buildUrlRefs
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
||||||
import com.vitorpamplona.quartz.nip92IMeta.IMetaTag
|
import com.vitorpamplona.quartz.nip92IMeta.IMetaTag
|
||||||
@@ -112,18 +114,11 @@ class TextNoteEvent(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
findHashtags(msg).forEach {
|
tags.addAll(buildHashtagTags(findHashtags(msg) + (extraTags ?: emptyList())))
|
||||||
val lowercaseTag = it.lowercase()
|
tags.addAll(buildUrlRefs(findURLs(msg)))
|
||||||
tags.add(arrayOf("t", it))
|
|
||||||
if (it != lowercaseTag) {
|
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
extraTags?.forEach { tags.add(arrayOf("t", it)) }
|
|
||||||
zapReceiver?.forEach {
|
zapReceiver?.forEach {
|
||||||
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
||||||
}
|
}
|
||||||
findURLs(msg).forEach { tags.add(arrayOf("r", it)) }
|
|
||||||
if (markAsSensitive) {
|
if (markAsSensitive) {
|
||||||
tags.add(arrayOf("content-warning", ""))
|
tags.add(arrayOf("content-warning", ""))
|
||||||
}
|
}
|
||||||
@@ -141,8 +136,6 @@ class TextNoteEvent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findURLs(text: String): List<String> = UrlDetector(text, UrlDetectorOptions.Default).detect().map { it.originalUrl }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of NIP-10 marked tags that are also ordered at best effort to support the
|
* Returns a list of NIP-10 marked tags that are also ordered at best effort to support the
|
||||||
* deprecated method of positional tags to maximize backwards compatibility with clients that
|
* deprecated method of positional tags to maximize backwards compatibility with clients that
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2024 Vitor Pamplona
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.vitorpamplona.quartz.nip10Notes.content
|
||||||
|
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
val hashtagSearch = Pattern.compile("(?:\\s|\\A)#([^\\s!@#\$%^&*()=+./,\\[{\\]};:'\"?><]+)")
|
||||||
|
|
||||||
|
fun findHashtags(
|
||||||
|
content: String,
|
||||||
|
output: MutableSet<String> = mutableSetOf(),
|
||||||
|
): List<String> {
|
||||||
|
val matcher = hashtagSearch.matcher(content)
|
||||||
|
while (matcher.find()) {
|
||||||
|
try {
|
||||||
|
val tag = matcher.group(1)
|
||||||
|
if (tag != null && tag.isNotBlank()) {
|
||||||
|
output.add(tag)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output.toList()
|
||||||
|
}
|
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2024 Vitor Pamplona
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.vitorpamplona.quartz.nip10Notes.content
|
||||||
|
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.TagArray
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
val tagSearch = Pattern.compile("(?:\\s|\\A)\\#\\[([0-9]+)\\]")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the old-style [1] tag that pionts to an index in the tag array
|
||||||
|
*/
|
||||||
|
fun findIndexTagsWithPeople(
|
||||||
|
content: String,
|
||||||
|
tags: TagArray,
|
||||||
|
output: MutableSet<String> = mutableSetOf<String>(),
|
||||||
|
): List<String> {
|
||||||
|
val matcher = tagSearch.matcher(content)
|
||||||
|
while (matcher.find()) {
|
||||||
|
try {
|
||||||
|
val tag = matcher.group(1)?.let { tags[it.toInt()] }
|
||||||
|
if (tag != null && tag.size > 1 && tag[0] == "p") {
|
||||||
|
output.add(tag[1])
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the old-style [1] tag that pionts to an index in the tag array
|
||||||
|
*/
|
||||||
|
fun findIndexTagsWithEventsOrAddresses(
|
||||||
|
content: String,
|
||||||
|
tags: TagArray,
|
||||||
|
output: MutableSet<String> = mutableSetOf<String>(),
|
||||||
|
): Set<String> {
|
||||||
|
val matcher = tagSearch.matcher(content)
|
||||||
|
while (matcher.find()) {
|
||||||
|
try {
|
||||||
|
val tag = matcher.group(1)?.let { tags[it.toInt()] }
|
||||||
|
if (tag != null && tag.size > 1 && tag[0] == "e") {
|
||||||
|
output.add(tag[1])
|
||||||
|
}
|
||||||
|
if (tag != null && tag.size > 1 && tag[0] == "a") {
|
||||||
|
output.add(tag[1])
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2024 Vitor Pamplona
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.vitorpamplona.quartz.nip10Notes.content
|
||||||
|
|
||||||
|
import com.linkedin.urls.detection.UrlDetector
|
||||||
|
import com.linkedin.urls.detection.UrlDetectorOptions
|
||||||
|
import com.vitorpamplona.quartz.nip96FileStorage.HttpUrlFormatter
|
||||||
|
|
||||||
|
fun findURLs(text: String): List<String> = UrlDetector(text, UrlDetectorOptions.Default).detect().map { it.originalUrl }
|
||||||
|
|
||||||
|
fun buildUrlRefs(urls: List<String>): List<Array<String>> =
|
||||||
|
urls
|
||||||
|
.mapTo(HashSet()) { url ->
|
||||||
|
HttpUrlFormatter.normalize(url)
|
||||||
|
}.map {
|
||||||
|
arrayOf("r", it)
|
||||||
|
}
|
@@ -129,6 +129,25 @@ object Nip19Parser {
|
|||||||
Log.w("NIP19 Parser", "Issue trying to Decode NIP19 $key: ${e.message}", e)
|
Log.w("NIP19 Parser", "Issue trying to Decode NIP19 $key: ${e.message}", e)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun parseAll(content: String): List<Entity> {
|
||||||
|
val matcher2 = nip19regex.matcher(content)
|
||||||
|
val returningList = mutableListOf<Entity>()
|
||||||
|
while (matcher2.find()) {
|
||||||
|
val type = matcher2.group(2) // npub1
|
||||||
|
val key = matcher2.group(3) // bech32
|
||||||
|
val additionalChars = matcher2.group(4) // additional chars
|
||||||
|
|
||||||
|
if (type != null) {
|
||||||
|
val parsed = Nip19Parser.parseComponents(type, key, additionalChars)?.entity
|
||||||
|
|
||||||
|
if (parsed != null) {
|
||||||
|
returningList.add(parsed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returningList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decodePublicKey(key: String): ByteArray =
|
fun decodePublicKey(key: String): ByteArray =
|
||||||
|
@@ -28,11 +28,13 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
|||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.BaseTextNoteEvent
|
import com.vitorpamplona.quartz.nip10Notes.BaseTextNoteEvent
|
||||||
import com.vitorpamplona.quartz.nip10Notes.ETag
|
import com.vitorpamplona.quartz.nip10Notes.ETag
|
||||||
import com.vitorpamplona.quartz.nip10Notes.PTag
|
import com.vitorpamplona.quartz.nip10Notes.PTag
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip10Notes.content.buildUrlRefs
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.parseAtag
|
import com.vitorpamplona.quartz.nip19Bech32.parseAtag
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
||||||
@@ -205,15 +207,8 @@ class CommentEvent(
|
|||||||
addressesMentioned.forEach { tags.add(it.toQTagArray()) }
|
addressesMentioned.forEach { tags.add(it.toQTagArray()) }
|
||||||
eventsMentioned.forEach { tags.add(it.toQTagArray()) }
|
eventsMentioned.forEach { tags.add(it.toQTagArray()) }
|
||||||
|
|
||||||
findHashtags(msg).forEach {
|
tags.addAll(buildHashtagTags(findHashtags(msg)))
|
||||||
val lowercaseTag = it.lowercase()
|
tags.addAll(buildUrlRefs(findURLs(msg)))
|
||||||
tags.add(arrayOf("t", it))
|
|
||||||
if (it != lowercaseTag) {
|
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
findURLs(msg).forEach { tags.add(arrayOf("r", it)) }
|
|
||||||
|
|
||||||
emojis?.forEach { tags.add(it.toTagArray()) }
|
emojis?.forEach { tags.add(it.toTagArray()) }
|
||||||
|
|
||||||
|
@@ -27,9 +27,11 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
|||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.BaseTextNoteEvent
|
import com.vitorpamplona.quartz.nip10Notes.BaseTextNoteEvent
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip10Notes.content.buildUrlRefs
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip10Notes.positionalMarkedTags
|
import com.vitorpamplona.quartz.nip10Notes.positionalMarkedTags
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.parse
|
import com.vitorpamplona.quartz.nip19Bech32.parse
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||||
@@ -93,7 +95,6 @@ class GitReplyEvent(
|
|||||||
replyTos: List<String>? = null,
|
replyTos: List<String>? = null,
|
||||||
mentions: List<String>? = null,
|
mentions: List<String>? = null,
|
||||||
addresses: List<ATag>? = null,
|
addresses: List<ATag>? = null,
|
||||||
extraTags: List<String>? = null,
|
|
||||||
zapReceiver: List<ZapSplitSetup>? = null,
|
zapReceiver: List<ZapSplitSetup>? = null,
|
||||||
markAsSensitive: Boolean = false,
|
markAsSensitive: Boolean = false,
|
||||||
zapRaiserAmount: Long? = null,
|
zapRaiserAmount: Long? = null,
|
||||||
@@ -146,15 +147,11 @@ class GitReplyEvent(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
findHashtags(msg).forEach {
|
tags.addAll(buildHashtagTags(findHashtags(msg)))
|
||||||
tags.add(arrayOf("t", it))
|
tags.addAll(buildUrlRefs(findURLs(msg)))
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
extraTags?.forEach { tags.add(arrayOf("t", it)) }
|
|
||||||
zapReceiver?.forEach {
|
zapReceiver?.forEach {
|
||||||
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
||||||
}
|
}
|
||||||
findURLs(msg).forEach { tags.add(arrayOf("r", it)) }
|
|
||||||
if (markAsSensitive) {
|
if (markAsSensitive) {
|
||||||
tags.add(arrayOf("content-warning", ""))
|
tags.add(arrayOf("content-warning", ""))
|
||||||
}
|
}
|
||||||
|
@@ -27,9 +27,11 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
|||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.BaseTextNoteEvent
|
import com.vitorpamplona.quartz.nip10Notes.BaseTextNoteEvent
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip10Notes.content.buildUrlRefs
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip10Notes.positionalMarkedTags
|
import com.vitorpamplona.quartz.nip10Notes.positionalMarkedTags
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
||||||
@@ -62,7 +64,6 @@ class TorrentCommentEvent(
|
|||||||
replyTos: List<String>? = null,
|
replyTos: List<String>? = null,
|
||||||
mentions: List<String>? = null,
|
mentions: List<String>? = null,
|
||||||
addresses: List<ATag>? = null,
|
addresses: List<ATag>? = null,
|
||||||
extraTags: List<String>? = null,
|
|
||||||
zapReceiver: List<ZapSplitSetup>? = null,
|
zapReceiver: List<ZapSplitSetup>? = null,
|
||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
@@ -116,18 +117,13 @@ class TorrentCommentEvent(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
findHashtags(message).forEach {
|
tags.addAll(buildHashtagTags(findHashtags(message)))
|
||||||
val lowercaseTag = it.lowercase()
|
tags.addAll(buildUrlRefs(findURLs(message)))
|
||||||
tags.add(arrayOf("t", it))
|
|
||||||
if (it != lowercaseTag) {
|
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
extraTags?.forEach { tags.add(arrayOf("t", it)) }
|
|
||||||
zapReceiver?.forEach {
|
zapReceiver?.forEach {
|
||||||
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
||||||
}
|
}
|
||||||
findURLs(message).forEach { tags.add(arrayOf("r", it)) }
|
|
||||||
if (markAsSensitive) {
|
if (markAsSensitive) {
|
||||||
tags.add(arrayOf("content-warning", ""))
|
tags.add(arrayOf("content-warning", ""))
|
||||||
}
|
}
|
||||||
|
@@ -26,10 +26,12 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
|||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.ETag
|
import com.vitorpamplona.quartz.nip10Notes.ETag
|
||||||
import com.vitorpamplona.quartz.nip10Notes.PTag
|
import com.vitorpamplona.quartz.nip10Notes.PTag
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip10Notes.content.buildUrlRefs
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip22Comments.RootScope
|
import com.vitorpamplona.quartz.nip22Comments.RootScope
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
||||||
import com.vitorpamplona.quartz.nip92IMeta.Nip92MediaAttachments.Companion.IMETA
|
import com.vitorpamplona.quartz.nip92IMeta.Nip92MediaAttachments.Companion.IMETA
|
||||||
@@ -182,15 +184,8 @@ class PictureEvent(
|
|||||||
eventsMentioned.forEach { tags.add(it.toQTagArray()) }
|
eventsMentioned.forEach { tags.add(it.toQTagArray()) }
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
findHashtags(msg).forEach {
|
tags.addAll(buildHashtagTags(findHashtags(msg)))
|
||||||
val lowercaseTag = it.lowercase()
|
tags.addAll(buildUrlRefs(findURLs(msg)))
|
||||||
tags.add(arrayOf("t", it))
|
|
||||||
if (it != lowercaseTag) {
|
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
findURLs(msg).forEach { tags.add(arrayOf("r", it)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zapReceiver?.forEach {
|
zapReceiver?.forEach {
|
||||||
|
@@ -26,8 +26,9 @@ import com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent
|
|||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohashMipMap
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findHashtags
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.buildHashtagTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
||||||
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
import com.vitorpamplona.quartz.nip57Zaps.ZapSplitSetup
|
||||||
import com.vitorpamplona.quartz.nip92IMeta.IMetaTag
|
import com.vitorpamplona.quartz.nip92IMeta.IMetaTag
|
||||||
@@ -169,11 +170,7 @@ class ClassifiedsEvent(
|
|||||||
location?.let { tags.add(arrayOf("location", it)) }
|
location?.let { tags.add(arrayOf("location", it)) }
|
||||||
publishedAt?.let { tags.add(arrayOf("publishedAt", it.toString())) }
|
publishedAt?.let { tags.add(arrayOf("publishedAt", it.toString())) }
|
||||||
condition?.let { tags.add(arrayOf("condition", it.value)) }
|
condition?.let { tags.add(arrayOf("condition", it.value)) }
|
||||||
|
tags.addAll(buildHashtagTags(findHashtags(message)))
|
||||||
findHashtags(message).forEach {
|
|
||||||
tags.add(arrayOf("t", it))
|
|
||||||
tags.add(arrayOf("t", it.lowercase()))
|
|
||||||
}
|
|
||||||
zapReceiver?.forEach {
|
zapReceiver?.forEach {
|
||||||
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user