fix build, use keyPair in textnoteevent, check if loggedInWithAmber in newpostview

This commit is contained in:
greenart7c3 2023-08-25 05:45:39 -03:00
parent a0308938de
commit 4f4d689f5a
5 changed files with 11 additions and 8 deletions

View File

@ -880,8 +880,7 @@ class Account(
root = root,
directMentions = directMentions,
geohash = geohash,
pubKey = keyPair.pubKey.toHexKey(),
privateKey = keyPair.privKey
keyPair = keyPair
)
if (!signEvent) {

View File

@ -30,6 +30,7 @@ import com.vitorpamplona.quartz.events.ReactionEvent
import com.vitorpamplona.quartz.events.ReportEvent
import com.vitorpamplona.quartz.events.RepostEvent
import com.vitorpamplona.quartz.events.SealedGossipEvent
import com.vitorpamplona.quartz.events.StatusEvent
import com.vitorpamplona.quartz.events.TextNoteEvent
object NostrAccountDataSource : NostrDataSource("AccountData") {

View File

@ -234,8 +234,10 @@ fun NewPostView(
PostButton(
onPost = {
scope.launch(Dispatchers.IO) {
postViewModel.sendPost(relayList = relayList)
onClose()
event = postViewModel.sendPost(relayList = relayList, !accountViewModel.loggedInWithAmber())
if (!accountViewModel.loggedInWithAmber()) {
onClose()
}
}
},
isActive = postViewModel.canPost()

View File

@ -143,7 +143,7 @@ fun SignerDialog(
verticalAlignment = Alignment.CenterVertically
) {
CloseButton(
onCancel = {
onPress = {
onClose()
}
)

View File

@ -6,6 +6,7 @@ import com.linkedin.urls.detection.UrlDetectorOptions
import com.vitorpamplona.quartz.utils.TimeUtils
import com.vitorpamplona.quartz.encoders.toHexKey
import com.vitorpamplona.quartz.crypto.CryptoUtils
import com.vitorpamplona.quartz.crypto.KeyPair
import com.vitorpamplona.quartz.encoders.ATag
import com.vitorpamplona.quartz.encoders.HexKey
@ -37,8 +38,7 @@ class TextNoteEvent(
root: String?,
directMentions: Set<HexKey>,
geohash: String? = null,
pubKey: HexKey,
privateKey: ByteArray?,
keyPair: KeyPair,
createdAt: Long = TimeUtils.now()
): TextNoteEvent {
val tags = mutableListOf<List<String>>()
@ -95,8 +95,9 @@ class TextNoteEvent(
tags.add(listOf("g", it))
}
val pubKey = keyPair.pubKey.toHexKey()
val id = generateId(pubKey, createdAt, kind, tags, msg)
val sig = if (privateKey == null) null else CryptoUtils.sign(id, privateKey)
val sig = if (keyPair.privKey == null) null else CryptoUtils.sign(id, keyPair.privKey)
return TextNoteEvent(id.toHexKey(), pubKey, createdAt, tags, msg, sig?.toHexKey() ?: "")
}
}