fix private zaps
This commit is contained in:
@@ -25,7 +25,6 @@ import com.vitorpamplona.quartz.encoders.ATag
|
|||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
import com.vitorpamplona.quartz.encoders.hexToByteArray
|
import com.vitorpamplona.quartz.encoders.hexToByteArray
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toNpub
|
|
||||||
import com.vitorpamplona.quartz.events.*
|
import com.vitorpamplona.quartz.events.*
|
||||||
import kotlinx.collections.immutable.ImmutableSet
|
import kotlinx.collections.immutable.ImmutableSet
|
||||||
import kotlinx.collections.immutable.persistentSetOf
|
import kotlinx.collections.immutable.persistentSetOf
|
||||||
@@ -118,8 +117,7 @@ class Account(
|
|||||||
AmberUtils.decryptBlockList(
|
AmberUtils.decryptBlockList(
|
||||||
content,
|
content,
|
||||||
keyPair.pubKey.toHexKey(),
|
keyPair.pubKey.toHexKey(),
|
||||||
blockList.id(),
|
blockList.id()
|
||||||
keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
blockList.decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
|
blockList.decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
|
||||||
live.invalidateData()
|
live.invalidateData()
|
||||||
@@ -222,7 +220,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val content = AmberUtils.content[event.id] ?: ""
|
val content = AmberUtils.content[event.id] ?: ""
|
||||||
if (content.isBlank()) {
|
if (content.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -244,7 +242,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val content = AmberUtils.content[event.id]
|
val content = AmberUtils.content[event.id]
|
||||||
if (content.isBlank()) {
|
if (content.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -316,7 +314,7 @@ class Account(
|
|||||||
keyPair
|
keyPair
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(senderReaction, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(senderReaction)
|
||||||
val reactionContent = AmberUtils.content[event.id]
|
val reactionContent = AmberUtils.content[event.id]
|
||||||
if (reactionContent.isBlank()) return
|
if (reactionContent.isBlank()) return
|
||||||
senderReaction = ReactionEvent.create(senderReaction, reactionContent)
|
senderReaction = ReactionEvent.create(senderReaction, reactionContent)
|
||||||
@@ -324,7 +322,7 @@ class Account(
|
|||||||
val giftWraps = users.plus(senderPublicKey).map {
|
val giftWraps = users.plus(senderPublicKey).map {
|
||||||
val gossip = Gossip.create(senderReaction)
|
val gossip = Gossip.create(senderReaction)
|
||||||
val content = Gossip.toJson(gossip)
|
val content = Gossip.toJson(gossip)
|
||||||
AmberUtils.encrypt(content, it, gossip.id!!, keyPair.pubKey.toNpub(), SignerType.NIP44_ENCRYPT)
|
AmberUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
|
||||||
val encryptedContent = AmberUtils.content[gossip.id]
|
val encryptedContent = AmberUtils.content[gossip.id]
|
||||||
if (encryptedContent.isBlank()) return
|
if (encryptedContent.isBlank()) return
|
||||||
|
|
||||||
@@ -332,7 +330,7 @@ class Account(
|
|||||||
encryptedContent = encryptedContent,
|
encryptedContent = encryptedContent,
|
||||||
pubKey = senderPublicKey
|
pubKey = senderPublicKey
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(sealedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(sealedEvent)
|
||||||
val eventContent = AmberUtils.content[sealedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[sealedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
sealedEvent = SealedGossipEvent.create(sealedEvent, eventContent)
|
sealedEvent = SealedGossipEvent.create(sealedEvent, eventContent)
|
||||||
@@ -369,7 +367,7 @@ class Account(
|
|||||||
keyPair
|
keyPair
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(senderReaction, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(senderReaction)
|
||||||
val reactionContent = AmberUtils.content[senderReaction.id] ?: ""
|
val reactionContent = AmberUtils.content[senderReaction.id] ?: ""
|
||||||
if (reactionContent.isBlank()) return
|
if (reactionContent.isBlank()) return
|
||||||
senderReaction = ReactionEvent.create(senderReaction, reactionContent)
|
senderReaction = ReactionEvent.create(senderReaction, reactionContent)
|
||||||
@@ -378,7 +376,7 @@ class Account(
|
|||||||
newUsers.forEach {
|
newUsers.forEach {
|
||||||
val gossip = Gossip.create(senderReaction)
|
val gossip = Gossip.create(senderReaction)
|
||||||
val content = Gossip.toJson(gossip)
|
val content = Gossip.toJson(gossip)
|
||||||
AmberUtils.encrypt(content, it, gossip.id!!, keyPair.pubKey.toNpub(), SignerType.NIP44_ENCRYPT)
|
AmberUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
|
||||||
val encryptedContent = AmberUtils.content[gossip.id]
|
val encryptedContent = AmberUtils.content[gossip.id]
|
||||||
if (encryptedContent.isBlank()) return
|
if (encryptedContent.isBlank()) return
|
||||||
|
|
||||||
@@ -386,7 +384,7 @@ class Account(
|
|||||||
encryptedContent = encryptedContent,
|
encryptedContent = encryptedContent,
|
||||||
pubKey = senderPublicKey
|
pubKey = senderPublicKey
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(sealedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(sealedEvent)
|
||||||
val sealedContent = AmberUtils.content[sealedEvent.id] ?: ""
|
val sealedContent = AmberUtils.content[sealedEvent.id] ?: ""
|
||||||
if (sealedContent.isBlank()) return
|
if (sealedContent.isBlank()) return
|
||||||
sealedEvent = SealedGossipEvent.create(sealedEvent, sealedContent)
|
sealedEvent = SealedGossipEvent.create(sealedEvent, sealedContent)
|
||||||
@@ -417,7 +415,7 @@ class Account(
|
|||||||
note.event?.let {
|
note.event?.let {
|
||||||
val event = ReactionEvent.create(emojiUrl, it, keyPair)
|
val event = ReactionEvent.create(emojiUrl, it, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.signEvent(event, keyPair.pubKey.toNpub())
|
AmberUtils.signEvent(event)
|
||||||
} else {
|
} else {
|
||||||
Client.send(event)
|
Client.send(event)
|
||||||
LocalCache.consume(event)
|
LocalCache.consume(event)
|
||||||
@@ -431,7 +429,7 @@ class Account(
|
|||||||
note.event?.let {
|
note.event?.let {
|
||||||
val event = ReactionEvent.create(reaction, it, keyPair)
|
val event = ReactionEvent.create(reaction, it, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.signEvent(event, keyPair.pubKey.toNpub())
|
AmberUtils.signEvent(event)
|
||||||
} else {
|
} else {
|
||||||
Client.send(event)
|
Client.send(event)
|
||||||
LocalCache.consume(event)
|
LocalCache.consume(event)
|
||||||
@@ -464,7 +462,7 @@ class Account(
|
|||||||
pollOption,
|
pollOption,
|
||||||
message
|
message
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(unsignedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(unsignedEvent)
|
||||||
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
if (content.isBlank()) return null
|
if (content.isBlank()) return null
|
||||||
|
|
||||||
@@ -483,7 +481,7 @@ class Account(
|
|||||||
pollOption,
|
pollOption,
|
||||||
message
|
message
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(unsignedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(unsignedEvent, "event")
|
||||||
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
if (content.isBlank()) return null
|
if (content.isBlank()) return null
|
||||||
|
|
||||||
@@ -533,7 +531,7 @@ class Account(
|
|||||||
|
|
||||||
if (privKey != null) return zapResponseEvent.response(privKey, pubKey)
|
if (privKey != null) return zapResponseEvent.response(privKey, pubKey)
|
||||||
|
|
||||||
AmberUtils.decrypt(zapResponseEvent.content, pubKey.toHexKey(), zapResponseEvent.id, keyPair.pubKey.toNpub())
|
AmberUtils.decrypt(zapResponseEvent.content, pubKey.toHexKey(), zapResponseEvent.id)
|
||||||
val decryptedContent = AmberUtils.content[zapResponseEvent.id] ?: ""
|
val decryptedContent = AmberUtils.content[zapResponseEvent.id] ?: ""
|
||||||
if (decryptedContent.isBlank()) return null
|
if (decryptedContent.isBlank()) return null
|
||||||
return zapResponseEvent.response(decryptedContent)
|
return zapResponseEvent.response(decryptedContent)
|
||||||
@@ -606,7 +604,7 @@ class Account(
|
|||||||
note.event?.let {
|
note.event?.let {
|
||||||
var event = ReactionEvent.createWarning(it, keyPair)
|
var event = ReactionEvent.createWarning(it, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
event = ReactionEvent(
|
event = ReactionEvent(
|
||||||
@@ -625,7 +623,7 @@ class Account(
|
|||||||
note.event?.let {
|
note.event?.let {
|
||||||
var event = ReportEvent.create(it, type, keyPair, content = content)
|
var event = ReportEvent.create(it, type, keyPair, content = content)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
event = ReportEvent(
|
event = ReportEvent(
|
||||||
@@ -652,7 +650,7 @@ class Account(
|
|||||||
|
|
||||||
var event = ReportEvent.create(user.pubkeyHex, type, keyPair)
|
var event = ReportEvent.create(user.pubkeyHex, type, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
event = ReportEvent(
|
event = ReportEvent(
|
||||||
@@ -680,7 +678,7 @@ class Account(
|
|||||||
if (myNotes.isNotEmpty()) {
|
if (myNotes.isNotEmpty()) {
|
||||||
val event = DeletionEvent.create(myNotes, keyPair)
|
val event = DeletionEvent.create(myNotes, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.signEvent(event, keyPair.pubKey.toNpub())
|
AmberUtils.signEvent(event)
|
||||||
} else {
|
} else {
|
||||||
Client.send(event)
|
Client.send(event)
|
||||||
LocalCache.consume(event)
|
LocalCache.consume(event)
|
||||||
@@ -693,7 +691,7 @@ class Account(
|
|||||||
|
|
||||||
var event = HTTPAuthorizationEvent.create(url, method, body, keyPair)
|
var event = HTTPAuthorizationEvent.create(url, method, body, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return null
|
return null
|
||||||
@@ -715,7 +713,7 @@ class Account(
|
|||||||
if (it.kind() == 1) {
|
if (it.kind() == 1) {
|
||||||
val event = RepostEvent.create(it, keyPair)
|
val event = RepostEvent.create(it, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.signEvent(event, keyPair.pubKey.toNpub())
|
AmberUtils.signEvent(event)
|
||||||
} else {
|
} else {
|
||||||
Client.send(event)
|
Client.send(event)
|
||||||
LocalCache.consume(event)
|
LocalCache.consume(event)
|
||||||
@@ -723,7 +721,7 @@ class Account(
|
|||||||
} else {
|
} else {
|
||||||
val event = GenericRepostEvent.create(it, keyPair)
|
val event = GenericRepostEvent.create(it, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.signEvent(event, keyPair.pubKey.toNpub())
|
AmberUtils.signEvent(event)
|
||||||
} else {
|
} else {
|
||||||
Client.send(event)
|
Client.send(event)
|
||||||
LocalCache.consume(event)
|
LocalCache.consume(event)
|
||||||
@@ -758,7 +756,7 @@ class Account(
|
|||||||
it,
|
it,
|
||||||
keyPair
|
keyPair
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(unsignedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(unsignedEvent)
|
||||||
val eventContent = AmberUtils.content[unsignedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
returningContactList = if (eventContent.isBlank()) {
|
returningContactList = if (eventContent.isBlank()) {
|
||||||
latestContactList
|
latestContactList
|
||||||
@@ -807,7 +805,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -839,7 +837,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -872,7 +870,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -908,7 +906,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -944,7 +942,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -969,7 +967,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -995,7 +993,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1021,7 +1019,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1047,7 +1045,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1073,7 +1071,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1096,7 +1094,7 @@ class Account(
|
|||||||
pubKey = keyPair.pubKey.toHexKey()
|
pubKey = keyPair.pubKey.toHexKey()
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(unsignedData, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(unsignedData)
|
||||||
val eventContent = AmberUtils.content[unsignedData.id] ?: ""
|
val eventContent = AmberUtils.content[unsignedData.id] ?: ""
|
||||||
if (eventContent.isBlank()) return null
|
if (eventContent.isBlank()) return null
|
||||||
val data = FileStorageEvent(
|
val data = FileStorageEvent(
|
||||||
@@ -1120,7 +1118,7 @@ class Account(
|
|||||||
pubKey = keyPair.pubKey.toHexKey()
|
pubKey = keyPair.pubKey.toHexKey()
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(unsignedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(unsignedEvent)
|
||||||
val unsignedEventContent = AmberUtils.content[unsignedEvent.id] ?: ""
|
val unsignedEventContent = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
if (unsignedEventContent.isBlank()) return null
|
if (unsignedEventContent.isBlank()) return null
|
||||||
val signedEvent = FileStorageHeaderEvent(
|
val signedEvent = FileStorageHeaderEvent(
|
||||||
@@ -1190,7 +1188,7 @@ class Account(
|
|||||||
sensitiveContent = headerInfo.sensitiveContent,
|
sensitiveContent = headerInfo.sensitiveContent,
|
||||||
keyPair = keyPair
|
keyPair = keyPair
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(unsignedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(unsignedEvent)
|
||||||
val eventContent = AmberUtils.content[unsignedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) return null
|
if (eventContent.isBlank()) return null
|
||||||
val signedEvent = FileHeaderEvent(
|
val signedEvent = FileHeaderEvent(
|
||||||
@@ -1257,7 +1255,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(signedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(signedEvent)
|
||||||
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1327,7 +1325,7 @@ class Account(
|
|||||||
// println("Sending new PollNoteEvent: %s".format(signedEvent.toJson()))
|
// println("Sending new PollNoteEvent: %s".format(signedEvent.toJson()))
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(signedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(signedEvent)
|
||||||
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1379,7 +1377,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(signedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(signedEvent)
|
||||||
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1420,7 +1418,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(signedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(signedEvent)
|
||||||
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1453,7 +1451,7 @@ class Account(
|
|||||||
|
|
||||||
var localMessage = message
|
var localMessage = message
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.encrypt(localMessage, toUser, "encrypt", keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(localMessage, toUser, "encrypt")
|
||||||
val eventContent = AmberUtils.content["encrypt"] ?: ""
|
val eventContent = AmberUtils.content["encrypt"] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
localMessage = eventContent
|
localMessage = eventContent
|
||||||
@@ -1475,7 +1473,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(signedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(signedEvent)
|
||||||
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
val eventContent = AmberUtils.content[signedEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1517,7 +1515,7 @@ class Account(
|
|||||||
geohash = geohash
|
geohash = geohash
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(chatMessageEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(chatMessageEvent)
|
||||||
val eventContent = AmberUtils.content[chatMessageEvent.id] ?: ""
|
val eventContent = AmberUtils.content[chatMessageEvent.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
chatMessageEvent = ChatMessageEvent.create(chatMessageEvent, eventContent)
|
chatMessageEvent = ChatMessageEvent.create(chatMessageEvent, eventContent)
|
||||||
@@ -1525,14 +1523,14 @@ class Account(
|
|||||||
toUsers.plus(senderPublicKey).toSet().forEach {
|
toUsers.plus(senderPublicKey).toSet().forEach {
|
||||||
val gossip = Gossip.create(chatMessageEvent)
|
val gossip = Gossip.create(chatMessageEvent)
|
||||||
val content = Gossip.toJson(gossip)
|
val content = Gossip.toJson(gossip)
|
||||||
AmberUtils.encrypt(content, it, gossip.id!!, keyPair.pubKey.toNpub(), SignerType.NIP44_ENCRYPT)
|
AmberUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
|
||||||
val gossipContent = AmberUtils.content[gossip.id] ?: ""
|
val gossipContent = AmberUtils.content[gossip.id] ?: ""
|
||||||
if (gossipContent.isNotBlank()) {
|
if (gossipContent.isNotBlank()) {
|
||||||
var sealedEvent = SealedGossipEvent.create(
|
var sealedEvent = SealedGossipEvent.create(
|
||||||
encryptedContent = gossipContent,
|
encryptedContent = gossipContent,
|
||||||
pubKey = senderPublicKey
|
pubKey = senderPublicKey
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(sealedEvent, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(sealedEvent)
|
||||||
val sealedEventContent = AmberUtils.content[sealedEvent.id] ?: ""
|
val sealedEventContent = AmberUtils.content[sealedEvent.id] ?: ""
|
||||||
if (sealedEventContent.isBlank()) return
|
if (sealedEventContent.isBlank()) return
|
||||||
sealedEvent = SealedGossipEvent.create(sealedEvent, sealedEventContent)
|
sealedEvent = SealedGossipEvent.create(sealedEvent, sealedEventContent)
|
||||||
@@ -1569,12 +1567,12 @@ class Account(
|
|||||||
// Only keep in cache the GiftWrap for the account.
|
// Only keep in cache the GiftWrap for the account.
|
||||||
if (it.recipientPubKey() == keyPair.pubKey.toHexKey()) {
|
if (it.recipientPubKey() == keyPair.pubKey.toHexKey()) {
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.decrypt(it.content, it.pubKey, it.id, keyPair.pubKey.toNpub(), SignerType.NIP44_DECRYPT)
|
AmberUtils.decrypt(it.content, it.pubKey, it.id, SignerType.NIP44_DECRYPT)
|
||||||
val decryptedContent = AmberUtils.cachedDecryptedContent[it.id] ?: ""
|
val decryptedContent = AmberUtils.cachedDecryptedContent[it.id] ?: ""
|
||||||
if (decryptedContent.isEmpty()) return
|
if (decryptedContent.isEmpty()) return
|
||||||
it.cachedGift(keyPair.pubKey, decryptedContent)?.let { cached ->
|
it.cachedGift(keyPair.pubKey, decryptedContent)?.let { cached ->
|
||||||
if (cached is SealedGossipEvent) {
|
if (cached is SealedGossipEvent) {
|
||||||
AmberUtils.decrypt(cached.content, cached.pubKey, cached.id, keyPair.pubKey.toNpub(), SignerType.NIP44_DECRYPT)
|
AmberUtils.decrypt(cached.content, cached.pubKey, cached.id, SignerType.NIP44_DECRYPT)
|
||||||
val localDecryptedContent = AmberUtils.cachedDecryptedContent[cached.id] ?: ""
|
val localDecryptedContent = AmberUtils.cachedDecryptedContent[cached.id] ?: ""
|
||||||
if (localDecryptedContent.isEmpty()) return
|
if (localDecryptedContent.isEmpty()) return
|
||||||
cached.cachedGossip(keyPair.pubKey, localDecryptedContent)?.let { gossip ->
|
cached.cachedGossip(keyPair.pubKey, localDecryptedContent)?.let { gossip ->
|
||||||
@@ -1616,7 +1614,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1638,7 +1636,7 @@ class Account(
|
|||||||
|
|
||||||
var event = StatusEvent.update(oldEvent, newStatus, keyPair)
|
var event = StatusEvent.update(oldEvent, newStatus, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1654,7 +1652,7 @@ class Account(
|
|||||||
|
|
||||||
var event = StatusEvent.create(newStatus, "general", expiration = null, keyPair)
|
var event = StatusEvent.create(newStatus, "general", expiration = null, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1671,7 +1669,7 @@ class Account(
|
|||||||
|
|
||||||
var event = StatusEvent.clear(oldEvent, keyPair)
|
var event = StatusEvent.clear(oldEvent, keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1683,7 +1681,7 @@ class Account(
|
|||||||
|
|
||||||
var event2 = DeletionEvent.create(listOf(event.id), keyPair)
|
var event2 = DeletionEvent.create(listOf(event.id), keyPair)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event2, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event2)
|
||||||
val event2Content = AmberUtils.content[event2.id] ?: ""
|
val event2Content = AmberUtils.content[event2.id] ?: ""
|
||||||
if (event2Content.isBlank()) {
|
if (event2Content.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1708,7 +1706,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1745,7 +1743,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1784,7 +1782,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
val msg = Event.mapper.writeValueAsString(privTags)
|
val msg = Event.mapper.writeValueAsString(privTags)
|
||||||
|
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt", keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
|
||||||
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
||||||
AmberUtils.content.remove("encrypt")
|
AmberUtils.content.remove("encrypt")
|
||||||
if (encryptedContent.isBlank()) {
|
if (encryptedContent.isBlank()) {
|
||||||
@@ -1802,7 +1800,7 @@ class Account(
|
|||||||
keyPair.pubKey.toHexKey()
|
keyPair.pubKey.toHexKey()
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1840,7 +1838,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
val msg = Event.mapper.writeValueAsString(privTags)
|
val msg = Event.mapper.writeValueAsString(privTags)
|
||||||
|
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt", keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
|
||||||
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
||||||
AmberUtils.content.remove("encrypt")
|
AmberUtils.content.remove("encrypt")
|
||||||
if (encryptedContent.isBlank()) {
|
if (encryptedContent.isBlank()) {
|
||||||
@@ -1858,7 +1856,7 @@ class Account(
|
|||||||
keyPair.pubKey.toHexKey()
|
keyPair.pubKey.toHexKey()
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -1926,7 +1924,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
val msg = Event.mapper.writeValueAsString(privTags)
|
val msg = Event.mapper.writeValueAsString(privTags)
|
||||||
|
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt", keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
|
||||||
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
||||||
AmberUtils.content.remove("encrypt")
|
AmberUtils.content.remove("encrypt")
|
||||||
if (encryptedContent.isBlank()) {
|
if (encryptedContent.isBlank()) {
|
||||||
@@ -1952,7 +1950,7 @@ class Account(
|
|||||||
keyPair.pubKey.toHexKey()
|
keyPair.pubKey.toHexKey()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -2042,7 +2040,7 @@ class Account(
|
|||||||
|
|
||||||
var event = RelayAuthEvent.create(relay.url, challenge, keyPair.pubKey.toHexKey(), keyPair.privKey)
|
var event = RelayAuthEvent.create(relay.url, challenge, keyPair.pubKey.toHexKey(), keyPair.privKey)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return null
|
return null
|
||||||
@@ -2110,7 +2108,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
val msg = Event.mapper.writeValueAsString(privTags)
|
val msg = Event.mapper.writeValueAsString(privTags)
|
||||||
|
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt", keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
|
||||||
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
val encryptedContent = AmberUtils.content["encrypt"] ?: ""
|
||||||
AmberUtils.content.remove("encrypt")
|
AmberUtils.content.remove("encrypt")
|
||||||
if (encryptedContent.isBlank()) {
|
if (encryptedContent.isBlank()) {
|
||||||
@@ -2137,7 +2135,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) {
|
if (eventContent.isBlank()) {
|
||||||
return
|
return
|
||||||
@@ -2215,7 +2213,7 @@ class Account(
|
|||||||
val privateTags = listOf(listOf("p", pubkeyHex))
|
val privateTags = listOf(listOf("p", pubkeyHex))
|
||||||
val msg = Event.mapper.writeValueAsString(privateTags)
|
val msg = Event.mapper.writeValueAsString(privateTags)
|
||||||
|
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt", keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
|
||||||
val encryptedContent = AmberUtils.content["encrypted"] ?: ""
|
val encryptedContent = AmberUtils.content["encrypted"] ?: ""
|
||||||
AmberUtils.content.remove("encrypted")
|
AmberUtils.content.remove("encrypted")
|
||||||
if (encryptedContent.isBlank()) return
|
if (encryptedContent.isBlank()) return
|
||||||
@@ -2223,7 +2221,7 @@ class Account(
|
|||||||
} else {
|
} else {
|
||||||
var decryptedContent = AmberUtils.cachedDecryptedContent[id]
|
var decryptedContent = AmberUtils.cachedDecryptedContent[id]
|
||||||
if (decryptedContent == null) {
|
if (decryptedContent == null) {
|
||||||
AmberUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), id, keyPair.pubKey.toNpub())
|
AmberUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), id)
|
||||||
val content = AmberUtils.content[id] ?: ""
|
val content = AmberUtils.content[id] ?: ""
|
||||||
if (content.isBlank()) return
|
if (content.isBlank()) return
|
||||||
decryptedContent = content
|
decryptedContent = content
|
||||||
@@ -2231,7 +2229,7 @@ class Account(
|
|||||||
|
|
||||||
val privateTags = blockList.privateTagsOrEmpty(decryptedContent).plus(element = listOf("p", pubkeyHex))
|
val privateTags = blockList.privateTagsOrEmpty(decryptedContent).plus(element = listOf("p", pubkeyHex))
|
||||||
val msg = Event.mapper.writeValueAsString(privateTags)
|
val msg = Event.mapper.writeValueAsString(privateTags)
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), id, keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), id)
|
||||||
val eventContent = AmberUtils.content[id] ?: ""
|
val eventContent = AmberUtils.content[id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
eventContent
|
eventContent
|
||||||
@@ -2255,7 +2253,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
event = PeopleListEvent(
|
event = PeopleListEvent(
|
||||||
@@ -2304,21 +2302,21 @@ class Account(
|
|||||||
val privateTags = listOf(listOf("p", pubkeyHex))
|
val privateTags = listOf(listOf("p", pubkeyHex))
|
||||||
val msg = Event.mapper.writeValueAsString(privateTags)
|
val msg = Event.mapper.writeValueAsString(privateTags)
|
||||||
|
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id, keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id)
|
||||||
val eventContent = AmberUtils.content[blockList.id] ?: ""
|
val eventContent = AmberUtils.content[blockList.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
eventContent
|
eventContent
|
||||||
} else {
|
} else {
|
||||||
var decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
|
var decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
|
||||||
if (decryptedContent == null) {
|
if (decryptedContent == null) {
|
||||||
AmberUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), blockList.id, keyPair.pubKey.toNpub())
|
AmberUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), blockList.id)
|
||||||
val eventContent = AmberUtils.content[blockList.id] ?: ""
|
val eventContent = AmberUtils.content[blockList.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
decryptedContent = eventContent
|
decryptedContent = eventContent
|
||||||
}
|
}
|
||||||
val privateTags = blockList.privateTagsOrEmpty(decryptedContent).minus(element = listOf("p", pubkeyHex))
|
val privateTags = blockList.privateTagsOrEmpty(decryptedContent).minus(element = listOf("p", pubkeyHex))
|
||||||
val msg = Event.mapper.writeValueAsString(privateTags)
|
val msg = Event.mapper.writeValueAsString(privateTags)
|
||||||
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id, keyPair.pubKey.toNpub())
|
AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id)
|
||||||
val eventContent = AmberUtils.content[blockList.id] ?: ""
|
val eventContent = AmberUtils.content[blockList.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
eventContent
|
eventContent
|
||||||
@@ -2332,7 +2330,7 @@ class Account(
|
|||||||
encryptedContent
|
encryptedContent
|
||||||
)
|
)
|
||||||
|
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
event = PeopleListEvent.create(event, eventContent)
|
event = PeopleListEvent.create(event, eventContent)
|
||||||
@@ -2547,7 +2545,7 @@ class Account(
|
|||||||
keyPair = keyPair
|
keyPair = keyPair
|
||||||
)
|
)
|
||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
AmberUtils.openAmber(event, keyPair.pubKey.toNpub())
|
AmberUtils.openAmber(event)
|
||||||
val eventContent = AmberUtils.content[event.id] ?: ""
|
val eventContent = AmberUtils.content[event.id] ?: ""
|
||||||
if (eventContent.isBlank()) return
|
if (eventContent.isBlank()) return
|
||||||
event = ChannelMetadataEvent.create(event, eventContent)
|
event = ChannelMetadataEvent.create(event, eventContent)
|
||||||
@@ -2565,7 +2563,7 @@ class Account(
|
|||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
var decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
|
var decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
|
||||||
if (decryptedContent == null) {
|
if (decryptedContent == null) {
|
||||||
AmberUtils.decrypt(event.content, event.pubKey, event.id, keyPair.pubKey.toNpub(), SignerType.NIP44_DECRYPT)
|
AmberUtils.decrypt(event.content, event.pubKey, event.id, SignerType.NIP44_DECRYPT)
|
||||||
}
|
}
|
||||||
decryptedContent = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
decryptedContent = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
||||||
if (decryptedContent.isEmpty()) return null
|
if (decryptedContent.isEmpty()) return null
|
||||||
@@ -2581,7 +2579,7 @@ class Account(
|
|||||||
if (loginWithAmber) {
|
if (loginWithAmber) {
|
||||||
var decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
|
var decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
|
||||||
if (decryptedContent == null) {
|
if (decryptedContent == null) {
|
||||||
AmberUtils.decrypt(event.content, event.pubKey, event.id, keyPair.pubKey.toNpub(), SignerType.NIP44_DECRYPT)
|
AmberUtils.decrypt(event.content, event.pubKey, event.id, SignerType.NIP44_DECRYPT)
|
||||||
}
|
}
|
||||||
decryptedContent = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
decryptedContent = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
||||||
if (decryptedContent.isEmpty()) return null
|
if (decryptedContent.isEmpty()) return null
|
||||||
@@ -2611,8 +2609,7 @@ class Account(
|
|||||||
AmberUtils.decryptDM(
|
AmberUtils.decryptDM(
|
||||||
event.content,
|
event.content,
|
||||||
event.talkingWith(userProfile().pubkeyHex),
|
event.talkingWith(userProfile().pubkeyHex),
|
||||||
event.id,
|
event.id
|
||||||
keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
AmberUtils.cachedDecryptedContent[event.id]
|
AmberUtils.cachedDecryptedContent[event.id]
|
||||||
} else {
|
} else {
|
||||||
@@ -2641,7 +2638,7 @@ class Account(
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AmberUtils.decryptZapEvent(event, keyPair.pubKey.toNpub())
|
AmberUtils.decryptZapEvent(event)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.vitorpamplona.amethyst.service.relays.Client
|
|||||||
import com.vitorpamplona.amethyst.ui.MainActivity
|
import com.vitorpamplona.amethyst.ui.MainActivity
|
||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
|
import com.vitorpamplona.quartz.encoders.toNpub
|
||||||
import com.vitorpamplona.quartz.events.Event
|
import com.vitorpamplona.quartz.events.Event
|
||||||
import com.vitorpamplona.quartz.events.EventInterface
|
import com.vitorpamplona.quartz.events.EventInterface
|
||||||
import com.vitorpamplona.quartz.events.LnZapRequestEvent
|
import com.vitorpamplona.quartz.events.LnZapRequestEvent
|
||||||
@@ -137,8 +138,7 @@ object AmberUtils {
|
|||||||
type: SignerType,
|
type: SignerType,
|
||||||
intentResult: ActivityResultLauncher<Intent>,
|
intentResult: ActivityResultLauncher<Intent>,
|
||||||
pubKey: HexKey,
|
pubKey: HexKey,
|
||||||
id: String,
|
id: String
|
||||||
currentUserNpub: HexKey
|
|
||||||
) {
|
) {
|
||||||
ServiceManager.shouldPauseService = false
|
ServiceManager.shouldPauseService = false
|
||||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$data"))
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$data"))
|
||||||
@@ -154,15 +154,17 @@ object AmberUtils {
|
|||||||
intent.putExtra("type", signerType)
|
intent.putExtra("type", signerType)
|
||||||
intent.putExtra("pubKey", pubKey)
|
intent.putExtra("pubKey", pubKey)
|
||||||
intent.putExtra("id", id)
|
intent.putExtra("id", id)
|
||||||
intent.putExtra("current_user", currentUserNpub)
|
if (type !== SignerType.GET_PUBLIC_KEY) {
|
||||||
|
intent.putExtra("current_user", account.keyPair.pubKey.toNpub())
|
||||||
|
}
|
||||||
intent.`package` = "com.greenart7c3.nostrsigner"
|
intent.`package` = "com.greenart7c3.nostrsigner"
|
||||||
intentResult.launch(intent)
|
intentResult.launch(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openAmber(event: EventInterface, currentUserNpub: HexKey) {
|
fun openAmber(event: EventInterface, columnName: String = "signature") {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
|
|
||||||
val result = getDataFromResolver(SignerType.SIGN_EVENT, arrayOf(event.toJson(), event.pubKey()), currentUserNpub)
|
val result = getDataFromResolver(SignerType.SIGN_EVENT, arrayOf(event.toJson(), event.pubKey()), columnName)
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(event.id(), result)
|
content.put(event.id(), result)
|
||||||
return
|
return
|
||||||
@@ -175,15 +177,14 @@ object AmberUtils {
|
|||||||
SignerType.SIGN_EVENT,
|
SignerType.SIGN_EVENT,
|
||||||
activityResultLauncher,
|
activityResultLauncher,
|
||||||
"",
|
"",
|
||||||
event.id(),
|
event.id()
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
while (isActivityRunning) {
|
while (isActivityRunning) {
|
||||||
Thread.sleep(100)
|
Thread.sleep(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun signEvent(event: EventInterface, currentUserNpub: HexKey) {
|
fun signEvent(event: EventInterface) {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
ServiceManager.shouldPauseService = false
|
ServiceManager.shouldPauseService = false
|
||||||
isActivityRunning = true
|
isActivityRunning = true
|
||||||
@@ -192,13 +193,12 @@ object AmberUtils {
|
|||||||
SignerType.SIGN_EVENT,
|
SignerType.SIGN_EVENT,
|
||||||
signEventResultLauncher,
|
signEventResultLauncher,
|
||||||
account.keyPair.pubKey.toHexKey(),
|
account.keyPair.pubKey.toHexKey(),
|
||||||
event.id(),
|
event.id()
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decryptBlockList(encryptedContent: String, pubKey: HexKey, id: String, currentUserNpub: HexKey, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
fun decryptBlockList(encryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
||||||
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey), currentUserNpub)
|
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey))
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(id, result)
|
content.put(id, result)
|
||||||
cachedDecryptedContent[id] = result
|
cachedDecryptedContent[id] = result
|
||||||
@@ -210,13 +210,17 @@ object AmberUtils {
|
|||||||
signerType,
|
signerType,
|
||||||
blockListResultLauncher,
|
blockListResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id,
|
id
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDataFromResolver(signerType: SignerType, data: Array<out String>, currentUserNpub: HexKey, columnName: String = "signature"): String? {
|
fun getDataFromResolver(signerType: SignerType, data: Array<out String>, columnName: String = "signature"): String? {
|
||||||
val localData = data.toList().plus(currentUserNpub).toTypedArray()
|
val localData = if (signerType !== SignerType.GET_PUBLIC_KEY) {
|
||||||
|
data.toList().plus(account.keyPair.pubKey.toNpub()).toTypedArray()
|
||||||
|
} else {
|
||||||
|
data
|
||||||
|
}
|
||||||
|
|
||||||
Amethyst.instance.contentResolver.query(
|
Amethyst.instance.contentResolver.query(
|
||||||
Uri.parse("content://com.greenart7c3.nostrsigner.$signerType"),
|
Uri.parse("content://com.greenart7c3.nostrsigner.$signerType"),
|
||||||
localData,
|
localData,
|
||||||
@@ -234,8 +238,8 @@ object AmberUtils {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decrypt(encryptedContent: String, pubKey: HexKey, id: String, currentUserNpub: HexKey, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
fun decrypt(encryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
||||||
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey), currentUserNpub)
|
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey))
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(id, result)
|
content.put(id, result)
|
||||||
cachedDecryptedContent[id] = result
|
cachedDecryptedContent[id] = result
|
||||||
@@ -248,16 +252,15 @@ object AmberUtils {
|
|||||||
signerType,
|
signerType,
|
||||||
decryptResultLauncher,
|
decryptResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id,
|
id
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
while (isActivityRunning) {
|
while (isActivityRunning) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decryptDM(encryptedContent: String, pubKey: HexKey, id: String, currentUserNpub: HexKey, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
fun decryptDM(encryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
||||||
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey), currentUserNpub)
|
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey))
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(id, result)
|
content.put(id, result)
|
||||||
cachedDecryptedContent[id] = result
|
cachedDecryptedContent[id] = result
|
||||||
@@ -268,13 +271,12 @@ object AmberUtils {
|
|||||||
signerType,
|
signerType,
|
||||||
decryptResultLauncher,
|
decryptResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id,
|
id
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decryptBookmark(encryptedContent: String, pubKey: HexKey, id: String, currentUserNpub: HexKey, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
fun decryptBookmark(encryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_DECRYPT) {
|
||||||
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey), currentUserNpub)
|
val result = getDataFromResolver(signerType, arrayOf(encryptedContent, pubKey))
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(id, result)
|
content.put(id, result)
|
||||||
cachedDecryptedContent[id] = result
|
cachedDecryptedContent[id] = result
|
||||||
@@ -285,13 +287,12 @@ object AmberUtils {
|
|||||||
signerType,
|
signerType,
|
||||||
decryptResultLauncher,
|
decryptResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id,
|
id
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun encrypt(decryptedContent: String, pubKey: HexKey, id: String, currentUserNpub: HexKey, signerType: SignerType = SignerType.NIP04_ENCRYPT) {
|
fun encrypt(decryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_ENCRYPT) {
|
||||||
val result = getDataFromResolver(signerType, arrayOf(decryptedContent, pubKey), currentUserNpub)
|
val result = getDataFromResolver(signerType, arrayOf(decryptedContent, pubKey))
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(id, result)
|
content.put(id, result)
|
||||||
return
|
return
|
||||||
@@ -303,16 +304,15 @@ object AmberUtils {
|
|||||||
signerType,
|
signerType,
|
||||||
activityResultLauncher,
|
activityResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id,
|
id
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
while (isActivityRunning) {
|
while (isActivityRunning) {
|
||||||
Thread.sleep(100)
|
Thread.sleep(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decryptZapEvent(event: LnZapRequestEvent, currentUserNpub: HexKey) {
|
fun decryptZapEvent(event: LnZapRequestEvent) {
|
||||||
val result = getDataFromResolver(SignerType.DECRYPT_ZAP_EVENT, arrayOf(event.toJson()), currentUserNpub)
|
val result = getDataFromResolver(SignerType.DECRYPT_ZAP_EVENT, arrayOf(event.toJson(), event.pubKey))
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
content.put(event.id, result)
|
content.put(event.id, result)
|
||||||
cachedDecryptedContent[event.id] = result
|
cachedDecryptedContent[event.id] = result
|
||||||
@@ -323,8 +323,7 @@ object AmberUtils {
|
|||||||
SignerType.DECRYPT_ZAP_EVENT,
|
SignerType.DECRYPT_ZAP_EVENT,
|
||||||
decryptResultLauncher,
|
decryptResultLauncher,
|
||||||
event.pubKey,
|
event.pubKey,
|
||||||
event.id,
|
event.id
|
||||||
currentUserNpub
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
|
|||||||
event.content,
|
event.content,
|
||||||
event.pubKey,
|
event.pubKey,
|
||||||
event.id,
|
event.id,
|
||||||
account.keyPair.pubKey.toNpub(),
|
|
||||||
SignerType.NIP44_DECRYPT
|
SignerType.NIP44_DECRYPT
|
||||||
)
|
)
|
||||||
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
||||||
@@ -186,7 +185,6 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
|
|||||||
event.content,
|
event.content,
|
||||||
event.pubKey,
|
event.pubKey,
|
||||||
event.id,
|
event.id,
|
||||||
account.keyPair.pubKey.toNpub(),
|
|
||||||
SignerType.NIP44_DECRYPT
|
SignerType.NIP44_DECRYPT
|
||||||
)
|
)
|
||||||
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
||||||
@@ -224,7 +222,7 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
|
|||||||
if (this::account.isInitialized) {
|
if (this::account.isInitialized) {
|
||||||
if (account.loginWithAmber) {
|
if (account.loginWithAmber) {
|
||||||
val event = RelayAuthEvent.create(relay.url, challenge, account.keyPair.pubKey.toHexKey(), account.keyPair.privKey)
|
val event = RelayAuthEvent.create(relay.url, challenge, account.keyPair.pubKey.toHexKey(), account.keyPair.privKey)
|
||||||
val result = AmberUtils.getDataFromResolver(SignerType.SIGN_EVENT, arrayOf(event.toJson(), account.keyPair.pubKey.toNpub()), account.keyPair.pubKey.toNpub(), "event")
|
val result = AmberUtils.getDataFromResolver(SignerType.SIGN_EVENT, arrayOf(event.toJson(), account.keyPair.pubKey.toNpub()), "event")
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
val signedEvent = Event.fromJson(result)
|
val signedEvent = Event.fromJson(result)
|
||||||
Client.send(
|
Client.send(
|
||||||
@@ -233,7 +231,7 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
AmberUtils.signEvent(event, account.keyPair.pubKey.toNpub())
|
AmberUtils.signEvent(event)
|
||||||
} else {
|
} else {
|
||||||
val event = account.createAuthEvent(relay, challenge)
|
val event = account.createAuthEvent(relay, challenge)
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
|
|||||||
-4
@@ -13,7 +13,6 @@ import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.sendDM
|
|||||||
import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.sendZapNotification
|
import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.sendZapNotification
|
||||||
import com.vitorpamplona.amethyst.ui.note.showAmount
|
import com.vitorpamplona.amethyst.ui.note.showAmount
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toNpub
|
|
||||||
import com.vitorpamplona.quartz.events.ChatMessageEvent
|
import com.vitorpamplona.quartz.events.ChatMessageEvent
|
||||||
import com.vitorpamplona.quartz.events.ChatroomKey
|
import com.vitorpamplona.quartz.events.ChatroomKey
|
||||||
import com.vitorpamplona.quartz.events.Event
|
import com.vitorpamplona.quartz.events.Event
|
||||||
@@ -50,7 +49,6 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
pushWrappedEvent.content,
|
pushWrappedEvent.content,
|
||||||
pushWrappedEvent.pubKey,
|
pushWrappedEvent.pubKey,
|
||||||
pushWrappedEvent.id,
|
pushWrappedEvent.id,
|
||||||
account.keyPair.pubKey.toNpub(),
|
|
||||||
SignerType.NIP44_DECRYPT
|
SignerType.NIP44_DECRYPT
|
||||||
)
|
)
|
||||||
cached = AmberUtils.cachedDecryptedContent[pushWrappedEvent.id] ?: ""
|
cached = AmberUtils.cachedDecryptedContent[pushWrappedEvent.id] ?: ""
|
||||||
@@ -108,7 +106,6 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
event.content,
|
event.content,
|
||||||
event.pubKey,
|
event.pubKey,
|
||||||
event.id,
|
event.id,
|
||||||
account.keyPair.pubKey.toNpub(),
|
|
||||||
SignerType.NIP44_DECRYPT
|
SignerType.NIP44_DECRYPT
|
||||||
)
|
)
|
||||||
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
||||||
@@ -135,7 +132,6 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
event.content,
|
event.content,
|
||||||
event.pubKey,
|
event.pubKey,
|
||||||
event.id,
|
event.id,
|
||||||
account.keyPair.pubKey.toNpub(),
|
|
||||||
SignerType.NIP44_DECRYPT
|
SignerType.NIP44_DECRYPT
|
||||||
)
|
)
|
||||||
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.vitorpamplona.amethyst.model.LocalCache
|
|||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.service.AmberUtils
|
import com.vitorpamplona.amethyst.service.AmberUtils
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toNpub
|
|
||||||
|
|
||||||
object BookmarkPrivateFeedFilter : FeedFilter<Note>() {
|
object BookmarkPrivateFeedFilter : FeedFilter<Note>() {
|
||||||
lateinit var account: Account
|
lateinit var account: Account
|
||||||
@@ -25,8 +24,7 @@ object BookmarkPrivateFeedFilter : FeedFilter<Note>() {
|
|||||||
AmberUtils.decryptBookmark(
|
AmberUtils.decryptBookmark(
|
||||||
bookmarks.content,
|
bookmarks.content,
|
||||||
account.keyPair.pubKey.toHexKey(),
|
account.keyPair.pubKey.toHexKey(),
|
||||||
id,
|
id
|
||||||
account.keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
bookmarks.decryptedContent = decryptedContent
|
bookmarks.decryptedContent = decryptedContent
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ReportNoteDialog
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ReportNoteDialog
|
||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toNpub
|
|
||||||
import kotlinx.collections.immutable.ImmutableSet
|
import kotlinx.collections.immutable.ImmutableSet
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -458,8 +457,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState<Boolean>, accountVi
|
|||||||
AmberUtils.decrypt(
|
AmberUtils.decrypt(
|
||||||
bookmarks?.content ?: "",
|
bookmarks?.content ?: "",
|
||||||
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
||||||
bookmarks?.id ?: "",
|
bookmarks?.id ?: ""
|
||||||
accountViewModel.account.keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
||||||
accountViewModel.removePrivateBookmark(note, bookmarks?.decryptedContent ?: "")
|
accountViewModel.removePrivateBookmark(note, bookmarks?.decryptedContent ?: "")
|
||||||
@@ -481,8 +479,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState<Boolean>, accountVi
|
|||||||
AmberUtils.decrypt(
|
AmberUtils.decrypt(
|
||||||
bookmarks?.content ?: "",
|
bookmarks?.content ?: "",
|
||||||
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
||||||
bookmarks?.id ?: "",
|
bookmarks?.id ?: ""
|
||||||
accountViewModel.account.keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
||||||
accountViewModel.addPrivateBookmark(note, bookmarks?.decryptedContent ?: "")
|
accountViewModel.addPrivateBookmark(note, bookmarks?.decryptedContent ?: "")
|
||||||
@@ -505,8 +502,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState<Boolean>, accountVi
|
|||||||
AmberUtils.decrypt(
|
AmberUtils.decrypt(
|
||||||
bookmarks?.content ?: "",
|
bookmarks?.content ?: "",
|
||||||
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
||||||
bookmarks?.id ?: "",
|
bookmarks?.id ?: ""
|
||||||
accountViewModel.account.keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
||||||
accountViewModel.removePublicBookmark(
|
accountViewModel.removePublicBookmark(
|
||||||
@@ -531,8 +527,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState<Boolean>, accountVi
|
|||||||
AmberUtils.decrypt(
|
AmberUtils.decrypt(
|
||||||
bookmarks?.content ?: "",
|
bookmarks?.content ?: "",
|
||||||
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
accountViewModel.account.keyPair.pubKey.toHexKey(),
|
||||||
bookmarks?.id ?: "",
|
bookmarks?.id ?: ""
|
||||||
accountViewModel.account.keyPair.pubKey.toNpub()
|
|
||||||
)
|
)
|
||||||
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
|
||||||
accountViewModel.addPublicBookmark(
|
accountViewModel.addPublicBookmark(
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ fun LoginPage(
|
|||||||
SignerType.GET_PUBLIC_KEY,
|
SignerType.GET_PUBLIC_KEY,
|
||||||
activity,
|
activity,
|
||||||
"",
|
"",
|
||||||
"",
|
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user