Fixes double quotes on NIP-28 Channel messages

This commit is contained in:
Vitor Pamplona 2024-12-24 15:53:45 -05:00
parent ff427d0fde
commit 92fcf05557
6 changed files with 33 additions and 6 deletions

View File

@ -2798,6 +2798,7 @@ class Account(
zapReceiver: List<ZapSplitSetup>? = null,
wantsToMarkAsSensitive: Boolean,
zapRaiserAmount: Long? = null,
directMentions: Set<HexKey>,
geohash: String? = null,
imetas: List<IMetaTag>? = null,
draftTag: String?,
@ -2815,6 +2816,7 @@ class Account(
zapReceiver = zapReceiver,
markAsSensitive = wantsToMarkAsSensitive,
zapRaiserAmount = zapRaiserAmount,
directMentions = directMentions,
geohash = geohash,
imetas = imetas,
signer = signer,

View File

@ -1402,6 +1402,10 @@ object LocalCache {
val replyTo = computeReplyTo(event)
if (event.id == "e01875f2f4c31a7512a56e677e135d6d2d28cbd7b7b0d5610e4b28fc4869f181") {
println("AABBCC ${replyTo.joinToString(",") { it.idHex} }")
}
note.loadEvent(event, author, replyTo)
// Log.d("CM", "New Chat Note (${note.author?.toBestDisplayName()} ${note.event?.content()}

View File

@ -609,6 +609,7 @@ open class NewPostViewModel : ViewModel() {
zapReceiver = zapReceiver,
wantsToMarkAsSensitive = wantsToMarkAsSensitive,
zapRaiserAmount = localZapRaiserAmount,
directMentions = tagger.directMentions,
geohash = geoHash,
imetas = usedAttachments,
draftTag = localDraft,

View File

@ -403,6 +403,7 @@ private suspend fun innerSendPost(
toChannel = channel.idHex,
replyTo = tagger.eTags,
mentions = tagger.pTags,
directMentions = tagger.directMentions,
wantsToMarkAsSensitive = false,
imetas = usedAttachments,
draftTag = draftTag,

View File

@ -194,10 +194,25 @@ open class BaseTextNoteEvent(
// removes forks from itself.
}.map { it.toTag() }
if (id == "e01875f2f4c31a7512a56e677e135d6d2d28cbd7b7b0d5610e4b28fc4869f181") {
val newStyleReply = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "reply" }?.get(1)
val newStyleRoot = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "root" }?.get(1)
println("AABBCC 1 Root: $newStyleRoot")
println("AABBCC 1 Reply: $newStyleReply")
println("AABBCC 1 Certain: ${certainRepliesTo.joinToString(",")}")
println("AABBCC 1 Uncertain: ${uncertainRepliesTo.joinToString(",")}")
}
if (certainRepliesTo.isEmpty() && uncertainRepliesTo.isEmpty() && tagAddresses.isEmpty()) return emptyList()
val citations = findCitations()
if (id == "e01875f2f4c31a7512a56e677e135d6d2d28cbd7b7b0d5610e4b28fc4869f181") {
println("AABBCC 2 ${citations.joinToString(",") { it }}")
}
return if (citations.isEmpty()) {
if (certainRepliesTo.isNotEmpty()) {
certainRepliesTo + tagAddresses

View File

@ -41,12 +41,9 @@ class ChannelMessageEvent(
tags.firstOrNull { it.size > 3 && it[0] == "e" && it[3] == "root" }?.get(1)
?: tags.firstOrNull { it.size > 1 && it[0] == "e" }?.get(1)
override fun markedReplyTos() =
tags
.filter { it.firstOrNull() == "e" && it.getOrNull(1) != channel() }
.mapNotNull { it.getOrNull(1) }
override fun markedReplyTos() = super.markedReplyTos().filter { it != channel() }
override fun unMarkedReplyTos() = emptyList<String>()
override fun unMarkedReplyTos() = super.unMarkedReplyTos().filter { it != channel() }
companion object {
const val KIND = 42
@ -62,6 +59,7 @@ class ChannelMessageEvent(
createdAt: Long = TimeUtils.now(),
markAsSensitive: Boolean,
zapRaiserAmount: Long?,
directMentions: Set<HexKey> = emptySet(),
geohash: String? = null,
imetas: List<IMetaTag>? = null,
isDraft: Boolean,
@ -71,8 +69,14 @@ class ChannelMessageEvent(
mutableListOf(
arrayOf("e", channel, "", "root"),
)
replyTos?.forEach { tags.add(arrayOf("e", it)) }
mentions?.forEach { tags.add(arrayOf("p", it)) }
replyTos?.forEach {
if (it in directMentions) {
tags.add(arrayOf("q", it))
} else {
tags.add(arrayOf("e", it))
}
}
zapReceiver?.forEach {
tags.add(arrayOf("zap", it.lnAddressOrPubKeyHex, it.relay ?: "", it.weight.toString()))
}