mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-09 22:52:36 +02:00
add signer support for sending notes
This commit is contained in:
@@ -833,9 +833,10 @@ class Account(
|
|||||||
root: String?,
|
root: String?,
|
||||||
directMentions: Set<HexKey>,
|
directMentions: Set<HexKey>,
|
||||||
relayList: List<Relay>? = null,
|
relayList: List<Relay>? = null,
|
||||||
geohash: String? = null
|
geohash: String? = null,
|
||||||
) {
|
signEvent: Boolean = true
|
||||||
if (!isWriteable()) return
|
): TextNoteEvent? {
|
||||||
|
if (!isWriteable() && signEvent) return null
|
||||||
|
|
||||||
val repliesToHex = replyTo?.filter { it.address() == null }?.map { it.idHex }
|
val repliesToHex = replyTo?.filter { it.address() == null }?.map { it.idHex }
|
||||||
val mentionsHex = mentions?.map { it.pubkeyHex }
|
val mentionsHex = mentions?.map { it.pubkeyHex }
|
||||||
@@ -854,11 +855,17 @@ class Account(
|
|||||||
root = root,
|
root = root,
|
||||||
directMentions = directMentions,
|
directMentions = directMentions,
|
||||||
geohash = geohash,
|
geohash = geohash,
|
||||||
privateKey = keyPair.privKey!!
|
pubKey = keyPair.pubKey.toHexKey(),
|
||||||
|
privateKey = keyPair.privKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!signEvent) {
|
||||||
|
return signedEvent
|
||||||
|
}
|
||||||
|
|
||||||
Client.send(signedEvent, relayList = relayList)
|
Client.send(signedEvent, relayList = relayList)
|
||||||
LocalCache.consume(signedEvent)
|
LocalCache.consume(signedEvent)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendPoll(
|
fun sendPoll(
|
||||||
@@ -874,9 +881,10 @@ class Account(
|
|||||||
wantsToMarkAsSensitive: Boolean,
|
wantsToMarkAsSensitive: Boolean,
|
||||||
zapRaiserAmount: Long? = null,
|
zapRaiserAmount: Long? = null,
|
||||||
relayList: List<Relay>? = null,
|
relayList: List<Relay>? = null,
|
||||||
geohash: String? = null
|
geohash: String? = null,
|
||||||
) {
|
signEvent: Boolean = true
|
||||||
if (!isWriteable()) return
|
): PollNoteEvent? {
|
||||||
|
if (!isWriteable() && signEvent) return null
|
||||||
|
|
||||||
val repliesToHex = replyTo?.map { it.idHex }
|
val repliesToHex = replyTo?.map { it.idHex }
|
||||||
val mentionsHex = mentions?.map { it.pubkeyHex }
|
val mentionsHex = mentions?.map { it.pubkeyHex }
|
||||||
@@ -887,7 +895,8 @@ class Account(
|
|||||||
replyTos = repliesToHex,
|
replyTos = repliesToHex,
|
||||||
mentions = mentionsHex,
|
mentions = mentionsHex,
|
||||||
addresses = addresses,
|
addresses = addresses,
|
||||||
privateKey = keyPair.privKey!!,
|
pubKey = keyPair.pubKey.toHexKey(),
|
||||||
|
privateKey = keyPair.privKey,
|
||||||
pollOptions = pollOptions,
|
pollOptions = pollOptions,
|
||||||
valueMaximum = valueMaximum,
|
valueMaximum = valueMaximum,
|
||||||
valueMinimum = valueMinimum,
|
valueMinimum = valueMinimum,
|
||||||
@@ -899,12 +908,28 @@ class Account(
|
|||||||
geohash = geohash
|
geohash = geohash
|
||||||
)
|
)
|
||||||
// println("Sending new PollNoteEvent: %s".format(signedEvent.toJson()))
|
// println("Sending new PollNoteEvent: %s".format(signedEvent.toJson()))
|
||||||
|
|
||||||
|
if (!signEvent) {
|
||||||
|
return signedEvent
|
||||||
|
}
|
||||||
|
|
||||||
Client.send(signedEvent, relayList = relayList)
|
Client.send(signedEvent, relayList = relayList)
|
||||||
LocalCache.consume(signedEvent)
|
LocalCache.consume(signedEvent)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendChannelMessage(message: String, toChannel: String, replyTo: List<Note>?, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
|
fun sendChannelMessage(
|
||||||
if (!isWriteable()) return
|
message: String,
|
||||||
|
toChannel: String,
|
||||||
|
replyTo: List<Note>?,
|
||||||
|
mentions: List<User>?,
|
||||||
|
zapReceiver: String? = null,
|
||||||
|
wantsToMarkAsSensitive: Boolean,
|
||||||
|
zapRaiserAmount: Long? = null,
|
||||||
|
geohash: String? = null,
|
||||||
|
signEvent: Boolean = true
|
||||||
|
): ChannelMessageEvent? {
|
||||||
|
if (!isWriteable() && signEvent) return null
|
||||||
|
|
||||||
// val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
// val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
||||||
val repliesToHex = replyTo?.map { it.idHex }
|
val repliesToHex = replyTo?.map { it.idHex }
|
||||||
@@ -919,14 +944,31 @@ class Account(
|
|||||||
markAsSensitive = wantsToMarkAsSensitive,
|
markAsSensitive = wantsToMarkAsSensitive,
|
||||||
zapRaiserAmount = zapRaiserAmount,
|
zapRaiserAmount = zapRaiserAmount,
|
||||||
geohash = geohash,
|
geohash = geohash,
|
||||||
privateKey = keyPair.privKey!!
|
pubKey = keyPair.pubKey.toHexKey(),
|
||||||
|
privateKey = keyPair.privKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!signEvent) {
|
||||||
|
return signedEvent
|
||||||
|
}
|
||||||
|
|
||||||
Client.send(signedEvent)
|
Client.send(signedEvent)
|
||||||
LocalCache.consume(signedEvent, null)
|
LocalCache.consume(signedEvent, null)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendLiveMessage(message: String, toChannel: ATag, replyTo: List<Note>?, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
|
fun sendLiveMessage(
|
||||||
if (!isWriteable()) return
|
message: String,
|
||||||
|
toChannel: ATag,
|
||||||
|
replyTo: List<Note>?,
|
||||||
|
mentions: List<User>?,
|
||||||
|
zapReceiver: String? = null,
|
||||||
|
wantsToMarkAsSensitive: Boolean,
|
||||||
|
zapRaiserAmount: Long? = null,
|
||||||
|
geohash: String? = null,
|
||||||
|
signEvent: Boolean = true
|
||||||
|
): LiveActivitiesChatMessageEvent? {
|
||||||
|
if (!isWriteable() && signEvent) return null
|
||||||
|
|
||||||
// val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
// val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
||||||
val repliesToHex = replyTo?.map { it.idHex }
|
val repliesToHex = replyTo?.map { it.idHex }
|
||||||
@@ -941,18 +983,35 @@ class Account(
|
|||||||
markAsSensitive = wantsToMarkAsSensitive,
|
markAsSensitive = wantsToMarkAsSensitive,
|
||||||
zapRaiserAmount = zapRaiserAmount,
|
zapRaiserAmount = zapRaiserAmount,
|
||||||
geohash = geohash,
|
geohash = geohash,
|
||||||
privateKey = keyPair.privKey!!
|
pubKey = keyPair.pubKey.toHexKey(),
|
||||||
|
privateKey = keyPair.privKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!signEvent) {
|
||||||
|
return signedEvent
|
||||||
|
}
|
||||||
|
|
||||||
Client.send(signedEvent)
|
Client.send(signedEvent)
|
||||||
LocalCache.consume(signedEvent, null)
|
LocalCache.consume(signedEvent, null)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendPrivateMessage(message: String, toUser: User, replyingTo: Note? = null, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
|
fun sendPrivateMessage(message: String, toUser: User, replyingTo: Note? = null, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null): PrivateDmEvent? {
|
||||||
sendPrivateMessage(message, toUser.pubkeyHex, replyingTo, mentions, zapReceiver, wantsToMarkAsSensitive, zapRaiserAmount, geohash)
|
return sendPrivateMessage(message, toUser.pubkeyHex, replyingTo, mentions, zapReceiver, wantsToMarkAsSensitive, zapRaiserAmount, geohash)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendPrivateMessage(message: String, toUser: HexKey, replyingTo: Note? = null, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
|
fun sendPrivateMessage(
|
||||||
if (!isWriteable()) return
|
message: String,
|
||||||
|
toUser: HexKey,
|
||||||
|
replyingTo: Note? = null,
|
||||||
|
mentions: List<User>?,
|
||||||
|
zapReceiver: String? = null,
|
||||||
|
wantsToMarkAsSensitive: Boolean,
|
||||||
|
zapRaiserAmount: Long? = null,
|
||||||
|
geohash: String? = null,
|
||||||
|
signEvent: Boolean = true
|
||||||
|
): PrivateDmEvent? {
|
||||||
|
if (!isWriteable() && signEvent) return null
|
||||||
|
|
||||||
val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
||||||
val mentionsHex = mentions?.map { it.pubkeyHex }
|
val mentionsHex = mentions?.map { it.pubkeyHex }
|
||||||
@@ -970,8 +1029,14 @@ class Account(
|
|||||||
privateKey = keyPair.privKey!!,
|
privateKey = keyPair.privKey!!,
|
||||||
advertiseNip18 = false
|
advertiseNip18 = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!signEvent) {
|
||||||
|
return signedEvent
|
||||||
|
}
|
||||||
|
|
||||||
Client.send(signedEvent)
|
Client.send(signedEvent)
|
||||||
LocalCache.consume(signedEvent, null)
|
LocalCache.consume(signedEvent, null)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendNIP24PrivateMessage(
|
fun sendNIP24PrivateMessage(
|
||||||
@@ -983,9 +1048,10 @@ class Account(
|
|||||||
zapReceiver: String? = null,
|
zapReceiver: String? = null,
|
||||||
wantsToMarkAsSensitive: Boolean,
|
wantsToMarkAsSensitive: Boolean,
|
||||||
zapRaiserAmount: Long? = null,
|
zapRaiserAmount: Long? = null,
|
||||||
geohash: String? = null
|
geohash: String? = null,
|
||||||
) {
|
signEvent: Boolean = true
|
||||||
if (!isWriteable()) return
|
): List<GiftWrapEvent>? {
|
||||||
|
if (!isWriteable() && signEvent) return null
|
||||||
|
|
||||||
val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
|
||||||
val mentionsHex = mentions?.map { it.pubkeyHex }
|
val mentionsHex = mentions?.map { it.pubkeyHex }
|
||||||
@@ -1003,7 +1069,12 @@ class Account(
|
|||||||
from = keyPair.privKey!!
|
from = keyPair.privKey!!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!signEvent) {
|
||||||
|
return signedEvents
|
||||||
|
}
|
||||||
|
|
||||||
broadcastPrivately(signedEvents)
|
broadcastPrivately(signedEvents)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun broadcastPrivately(signedEvents: List<GiftWrapEvent>) {
|
fun broadcastPrivately(signedEvents: List<GiftWrapEvent>) {
|
||||||
|
@@ -33,14 +33,14 @@ class ChannelMessageEvent(
|
|||||||
replyTos: List<String>? = null,
|
replyTos: List<String>? = null,
|
||||||
mentions: List<String>? = null,
|
mentions: List<String>? = null,
|
||||||
zapReceiver: String?,
|
zapReceiver: String?,
|
||||||
privateKey: ByteArray,
|
pubKey: HexKey,
|
||||||
|
privateKey: ByteArray?,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
markAsSensitive: Boolean,
|
markAsSensitive: Boolean,
|
||||||
zapRaiserAmount: Long?,
|
zapRaiserAmount: Long?,
|
||||||
geohash: String? = null
|
geohash: String? = null
|
||||||
): ChannelMessageEvent {
|
): ChannelMessageEvent {
|
||||||
val content = message
|
val content = message
|
||||||
val pubKey = CryptoUtils.pubkeyCreate(privateKey).toHexKey()
|
|
||||||
val tags = mutableListOf(
|
val tags = mutableListOf(
|
||||||
listOf("e", channel, "", "root")
|
listOf("e", channel, "", "root")
|
||||||
)
|
)
|
||||||
@@ -64,8 +64,8 @@ class ChannelMessageEvent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val id = generateId(pubKey, createdAt, kind, tags, content)
|
val id = generateId(pubKey, createdAt, kind, tags, content)
|
||||||
val sig = CryptoUtils.sign(id, privateKey)
|
val sig = if (privateKey == null) null else CryptoUtils.sign(id, privateKey)
|
||||||
return ChannelMessageEvent(id.toHexKey(), pubKey, createdAt, tags, content, sig.toHexKey())
|
return ChannelMessageEvent(id.toHexKey(), pubKey, createdAt, tags, content, sig?.toHexKey() ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,14 +48,14 @@ class LiveActivitiesChatMessageEvent(
|
|||||||
replyTos: List<String>? = null,
|
replyTos: List<String>? = null,
|
||||||
mentions: List<String>? = null,
|
mentions: List<String>? = null,
|
||||||
zapReceiver: String?,
|
zapReceiver: String?,
|
||||||
privateKey: ByteArray,
|
pubKey: HexKey,
|
||||||
|
privateKey: ByteArray?,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
markAsSensitive: Boolean,
|
markAsSensitive: Boolean,
|
||||||
zapRaiserAmount: Long?,
|
zapRaiserAmount: Long?,
|
||||||
geohash: String? = null
|
geohash: String? = null
|
||||||
): LiveActivitiesChatMessageEvent {
|
): LiveActivitiesChatMessageEvent {
|
||||||
val content = message
|
val content = message
|
||||||
val pubKey = CryptoUtils.pubkeyCreate(privateKey).toHexKey()
|
|
||||||
val tags = mutableListOf(
|
val tags = mutableListOf(
|
||||||
listOf("a", activity.toTag(), "", "root")
|
listOf("a", activity.toTag(), "", "root")
|
||||||
)
|
)
|
||||||
@@ -79,8 +79,8 @@ class LiveActivitiesChatMessageEvent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val id = generateId(pubKey, createdAt, kind, tags, content)
|
val id = generateId(pubKey, createdAt, kind, tags, content)
|
||||||
val sig = CryptoUtils.sign(id, privateKey)
|
val sig = if (privateKey == null) null else CryptoUtils.sign(id, privateKey)
|
||||||
return LiveActivitiesChatMessageEvent(id.toHexKey(), pubKey, createdAt, tags, content, sig.toHexKey())
|
return LiveActivitiesChatMessageEvent(id.toHexKey(), pubKey, createdAt, tags, content, sig?.toHexKey() ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,8 @@ class PollNoteEvent(
|
|||||||
replyTos: List<String>?,
|
replyTos: List<String>?,
|
||||||
mentions: List<String>?,
|
mentions: List<String>?,
|
||||||
addresses: List<ATag>?,
|
addresses: List<ATag>?,
|
||||||
privateKey: ByteArray,
|
pubKey: HexKey,
|
||||||
|
privateKey: ByteArray?,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
pollOptions: Map<Int, String>,
|
pollOptions: Map<Int, String>,
|
||||||
valueMaximum: Int?,
|
valueMaximum: Int?,
|
||||||
@@ -56,7 +57,6 @@ class PollNoteEvent(
|
|||||||
zapRaiserAmount: Long?,
|
zapRaiserAmount: Long?,
|
||||||
geohash: String? = null
|
geohash: String? = null
|
||||||
): PollNoteEvent {
|
): PollNoteEvent {
|
||||||
val pubKey = CryptoUtils.pubkeyCreate(privateKey).toHexKey()
|
|
||||||
val tags = mutableListOf<List<String>>()
|
val tags = mutableListOf<List<String>>()
|
||||||
replyTos?.forEach {
|
replyTos?.forEach {
|
||||||
tags.add(listOf("e", it))
|
tags.add(listOf("e", it))
|
||||||
@@ -89,8 +89,8 @@ class PollNoteEvent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val id = generateId(pubKey, createdAt, kind, tags, msg)
|
val id = generateId(pubKey, createdAt, kind, tags, msg)
|
||||||
val sig = CryptoUtils.sign(id, privateKey)
|
val sig = if (privateKey == null) null else CryptoUtils.sign(id, privateKey)
|
||||||
return PollNoteEvent(id.toHexKey(), pubKey, createdAt, tags, msg, sig.toHexKey())
|
return PollNoteEvent(id.toHexKey(), pubKey, createdAt, tags, msg, sig?.toHexKey() ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,11 +37,10 @@ class TextNoteEvent(
|
|||||||
root: String?,
|
root: String?,
|
||||||
directMentions: Set<HexKey>,
|
directMentions: Set<HexKey>,
|
||||||
geohash: String? = null,
|
geohash: String? = null,
|
||||||
|
pubKey: HexKey,
|
||||||
privateKey: ByteArray,
|
privateKey: ByteArray?,
|
||||||
createdAt: Long = TimeUtils.now()
|
createdAt: Long = TimeUtils.now()
|
||||||
): TextNoteEvent {
|
): TextNoteEvent {
|
||||||
val pubKey = CryptoUtils.pubkeyCreate(privateKey).toHexKey()
|
|
||||||
val tags = mutableListOf<List<String>>()
|
val tags = mutableListOf<List<String>>()
|
||||||
replyTos?.forEach {
|
replyTos?.forEach {
|
||||||
if (it == replyingTo) {
|
if (it == replyingTo) {
|
||||||
@@ -97,8 +96,8 @@ class TextNoteEvent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val id = generateId(pubKey, createdAt, kind, tags, msg)
|
val id = generateId(pubKey, createdAt, kind, tags, msg)
|
||||||
val sig = CryptoUtils.sign(id, privateKey)
|
val sig = if (privateKey == null) null else CryptoUtils.sign(id, privateKey)
|
||||||
return TextNoteEvent(id.toHexKey(), pubKey, createdAt, tags, msg, sig.toHexKey())
|
return TextNoteEvent(id.toHexKey(), pubKey, createdAt, tags, msg, sig?.toHexKey() ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -75,12 +75,15 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi
|
|||||||
import com.google.accompanist.permissions.isGranted
|
import com.google.accompanist.permissions.isGranted
|
||||||
import com.google.accompanist.permissions.rememberPermissionState
|
import com.google.accompanist.permissions.rememberPermissionState
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.ServersAvailable
|
import com.vitorpamplona.amethyst.model.ServersAvailable
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.service.NostrSearchEventOrUserDataSource
|
import com.vitorpamplona.amethyst.service.NostrSearchEventOrUserDataSource
|
||||||
import com.vitorpamplona.amethyst.service.ReverseGeoLocationUtil
|
import com.vitorpamplona.amethyst.service.ReverseGeoLocationUtil
|
||||||
|
import com.vitorpamplona.amethyst.service.model.Event
|
||||||
import com.vitorpamplona.amethyst.service.noProtocolUrlValidator
|
import com.vitorpamplona.amethyst.service.noProtocolUrlValidator
|
||||||
|
import com.vitorpamplona.amethyst.service.relays.Client
|
||||||
import com.vitorpamplona.amethyst.ui.components.*
|
import com.vitorpamplona.amethyst.ui.components.*
|
||||||
import com.vitorpamplona.amethyst.ui.note.CancelIcon
|
import com.vitorpamplona.amethyst.ui.note.CancelIcon
|
||||||
import com.vitorpamplona.amethyst.ui.note.CloseIcon
|
import com.vitorpamplona.amethyst.ui.note.CloseIcon
|
||||||
@@ -158,6 +161,24 @@ fun NewPostView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var event by remember { mutableStateOf<Event?>(null) }
|
||||||
|
if (event != null) {
|
||||||
|
SignerDialog(
|
||||||
|
onClose = {
|
||||||
|
event = null
|
||||||
|
},
|
||||||
|
onPost = {
|
||||||
|
scope.launch(Dispatchers.IO) {
|
||||||
|
Client.send(it, relayList = relayList)
|
||||||
|
LocalCache.verifyAndConsume(it, null)
|
||||||
|
event = null
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event = event!!
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = { onClose() },
|
onDismissRequest = { onClose() },
|
||||||
properties = DialogProperties(
|
properties = DialogProperties(
|
||||||
@@ -224,8 +245,10 @@ fun NewPostView(
|
|||||||
PostButton(
|
PostButton(
|
||||||
onPost = {
|
onPost = {
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
postViewModel.sendPost(relayList = relayList)
|
event = postViewModel.sendPost(relayList = relayList, signEvent = account.keyPair.privKey != null)
|
||||||
onClose()
|
if (event == null) {
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isActive = postViewModel.canPost()
|
isActive = postViewModel.canPost()
|
||||||
|
@@ -22,6 +22,7 @@ import com.vitorpamplona.amethyst.service.model.AddressableEvent
|
|||||||
import com.vitorpamplona.amethyst.service.model.BaseTextNoteEvent
|
import com.vitorpamplona.amethyst.service.model.BaseTextNoteEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.ChatMessageEvent
|
import com.vitorpamplona.amethyst.service.model.ChatMessageEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.CommunityDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.CommunityDefinitionEvent
|
||||||
|
import com.vitorpamplona.amethyst.service.model.Event
|
||||||
import com.vitorpamplona.amethyst.service.model.PrivateDmEvent
|
import com.vitorpamplona.amethyst.service.model.PrivateDmEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.TextNoteEvent
|
import com.vitorpamplona.amethyst.service.model.TextNoteEvent
|
||||||
import com.vitorpamplona.amethyst.service.noProtocolUrlValidator
|
import com.vitorpamplona.amethyst.service.noProtocolUrlValidator
|
||||||
@@ -156,7 +157,7 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
this.account = account
|
this.account = account
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendPost(relayList: List<Relay>? = null) {
|
fun sendPost(relayList: List<Relay>? = null, signEvent: Boolean = true): Event? {
|
||||||
val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex())
|
val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex())
|
||||||
tagger.run()
|
tagger.run()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user