Merge branch 'vitorpamplona:main' into labeled-bookmarks

This commit is contained in:
KotlinGeekDev
2025-11-26 21:45:35 +00:00
committed by GitHub
13 changed files with 486 additions and 37 deletions
@@ -24,10 +24,12 @@ import androidx.compose.runtime.Immutable
import com.vitorpamplona.quartz.experimental.relationshipStatus.tags.PetNameTag
import com.vitorpamplona.quartz.experimental.relationshipStatus.tags.RankTag
import com.vitorpamplona.quartz.experimental.relationshipStatus.tags.SummaryTag
import com.vitorpamplona.quartz.nip01Core.core.Address
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
import com.vitorpamplona.quartz.nip01Core.core.tagArray
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag
import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag
import com.vitorpamplona.quartz.nip31Alts.alt
import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEvent
@@ -49,10 +51,20 @@ class ContactCardEvent(
fun summary() = tags.firstNotNullOfOrNull(SummaryTag::parse)
companion object Companion {
companion object {
const val KIND = 30382
const val ALT = "Contact Card"
fun createAddress(
owner: HexKey,
target: HexKey,
): Address = Address(KIND, owner, target)
fun createAddressTag(
owner: HexKey,
target: HexKey,
): ATag = ATag(KIND, owner, target, null)
suspend fun create(
targetUser: HexKey,
petName: String? = null,
@@ -61,28 +61,3 @@ data class ServiceProviderTag(
fun assemble(id: ServiceProviderTag) = arrayOf(id.service, id.pubkey, id.relayUrl)
}
}
data class ServiceType(
val kind: Int,
val type: String,
) {
fun toValue() = assemble(kind, type)
companion object {
fun assemble(
kind: Int,
type: String,
) = "$kind:$type"
fun parse(serviceType: String): ServiceType? {
val (kindStr, type) = serviceType.split(":", limit = 2)
val kind = kindStr.toIntOrNull() ?: return null
return ServiceType(kind, type)
}
fun isOfKind(
serviceType: String,
kind: String,
) = serviceType.startsWith(kind) && serviceType[kind.length] == ':'
}
}
@@ -0,0 +1,67 @@
/**
* Copyright (c) 2025 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.experimental.trustedAssertions.list.tags
data class ServiceType(
val kind: Int,
val type: String,
) {
fun toValue() = assemble(kind, type)
companion object {
fun assemble(
kind: Int,
type: String,
) = "$kind:$type"
fun parse(serviceType: String): ServiceType? {
val (kindStr, type) = serviceType.split(":", limit = 2)
val kind = kindStr.toIntOrNull() ?: return null
return ServiceType(kind, type)
}
fun isOfKind(
serviceType: String,
kind: String,
) = serviceType.startsWith(kind) && serviceType[kind.length] == ':'
}
}
object ProviderTypes {
val rank = ServiceType(30382, "rank")
val followerCount = ServiceType(30382, "followers")
val firstPost = ServiceType(30382, "first_created_at")
val postCount = ServiceType(30382, "post_cnt")
val replyCount = ServiceType(30382, "reply_cnt")
val reactionsCount = ServiceType(30382, "reactions_cnt")
val zapReceivedAmount = ServiceType(30382, "zap_amt_recd")
val zapSentAmount = ServiceType(30382, "zap_amt_sent")
val zapReceivedCount = ServiceType(30382, "zap_cnt_recd")
val zapSentCount = ServiceType(30382, "zap_cnt_sent")
val averageZapAmountReceivedPerDay = ServiceType(30382, "zap_avg_amt_day_recd")
val averageZapAmountSentPerDay = ServiceType(30382, "zap_avg_amt_day_sent")
val reportsReceivedCount = ServiceType(30382, "reports_cnt_recd")
val reportsSentCount = ServiceType(30382, "reports_cnt_sent")
val topics = ServiceType(30382, "t")
val activeFrom = ServiceType(30382, "active_hours_start")
val activeTo = ServiceType(30382, "active_hours_end")
}
@@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.utils.sha256
import java.io.InputStream
val pool = Sha256Pool(5) // max parallel operations
val pool = Sha256Pool(10) // max parallel operations
actual fun sha256(data: ByteArray) = pool.hash(data)