mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-30 00:40:49 +00:00
decode private zaps and show in notifications + show zap messages
This commit is contained in:
parent
37bd7e34a0
commit
a13dbf2bda
@ -594,17 +594,6 @@ object LocalCache {
|
||||
|
||||
fun consume(event: LnZapEvent) {
|
||||
val note = getOrCreateNote(event.id)
|
||||
|
||||
var decryptedContent = LnZapRequestEvent.checkForPrivateZap(event.zapRequest!!, account.loggedIn.privKey!!)
|
||||
if (decryptedContent != null) {
|
||||
Log.e(
|
||||
"DC",
|
||||
"Decrypted Content from Anon Tag: Sender: {${decryptedContent.pubKey}}, Message: {${decryptedContent.content}} "
|
||||
|
||||
// TODO Update Notification with this Sender and Message
|
||||
)
|
||||
}
|
||||
|
||||
// Already processed this event.
|
||||
if (note.event != null) return
|
||||
|
||||
|
@ -19,7 +19,7 @@ open class Event(
|
||||
@SerializedName("created_at") val createdAt: Long,
|
||||
val kind: Int,
|
||||
val tags: List<List<String>>,
|
||||
val content: String,
|
||||
var content: String,
|
||||
val sig: HexKey
|
||||
) : EventInterface {
|
||||
override fun id(): HexKey = id
|
||||
|
@ -36,8 +36,13 @@ import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.NostrAccountDataSource
|
||||
import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent
|
||||
import com.vitorpamplona.amethyst.service.model.Event
|
||||
import com.vitorpamplona.amethyst.service.model.LnZapEvent
|
||||
import com.vitorpamplona.amethyst.service.model.LnZapRequestEvent
|
||||
import com.vitorpamplona.amethyst.service.model.PrivateDmEvent
|
||||
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
||||
import com.vitorpamplona.amethyst.ui.screen.MultiSetCard
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
||||
@ -135,7 +140,16 @@ fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accoun
|
||||
)
|
||||
}
|
||||
|
||||
AuthorGallery(multiSetCard.zapEvents.keys, navController, account)
|
||||
for (i in multiSetCard.zapEvents) {
|
||||
var decryptedContent = (i.value.event as LnZapEvent).zapRequest?.let {
|
||||
LnZapRequestEvent.checkForPrivateZap(it, NostrAccountDataSource.account.loggedIn.privKey!!)
|
||||
}
|
||||
if (decryptedContent != null) {
|
||||
(i.key.event as Event).content = decryptedContent.content
|
||||
i.key.author = LocalCache.getOrCreateUser(decryptedContent.pubKey)
|
||||
}
|
||||
}
|
||||
AuthorGallery(multiSetCard.zapEvents.keys, navController, account, accountViewModel, "zap")
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +170,7 @@ fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accoun
|
||||
)
|
||||
}
|
||||
|
||||
AuthorGallery(multiSetCard.boostEvents, navController, account)
|
||||
AuthorGallery(multiSetCard.boostEvents, navController, account, accountViewModel)
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +191,7 @@ fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accoun
|
||||
)
|
||||
}
|
||||
|
||||
AuthorGallery(multiSetCard.likeEvents, navController, account)
|
||||
AuthorGallery(multiSetCard.likeEvents, navController, account, accountViewModel)
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +225,9 @@ fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accoun
|
||||
fun AuthorGallery(
|
||||
authorNotes: Collection<Note>,
|
||||
navController: NavController,
|
||||
account: Account
|
||||
account: Account,
|
||||
accountViewModel: AccountViewModel,
|
||||
kind: String = "nonzap"
|
||||
) {
|
||||
val accountState by account.userProfile().live().follows.observeAsState()
|
||||
val accountUser = accountState?.user ?: return
|
||||
@ -219,12 +235,39 @@ fun AuthorGallery(
|
||||
Column(modifier = Modifier.padding(start = 10.dp)) {
|
||||
FlowRow() {
|
||||
authorNotes.forEach {
|
||||
FastNoteAuthorPicture(
|
||||
note = it,
|
||||
navController = navController,
|
||||
userAccount = accountUser,
|
||||
size = 35.dp
|
||||
)
|
||||
if (it.event?.content() != "" && kind == "zap") {
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
FastNoteAuthorPicture(
|
||||
note = it,
|
||||
navController = navController,
|
||||
userAccount = accountUser,
|
||||
size = 35.dp
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Row() {
|
||||
FastNoteAuthorPicture(
|
||||
note = it,
|
||||
navController = navController,
|
||||
userAccount = accountUser,
|
||||
size = 35.dp
|
||||
)
|
||||
}
|
||||
}
|
||||
if (it.event?.content() != "" && kind == "zap") {
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
it.event?.let {
|
||||
TranslatableRichTextViewer(
|
||||
content = it.content(),
|
||||
canPreview = true,
|
||||
tags = null,
|
||||
backgroundColor = MaterialTheme.colors.background,
|
||||
accountViewModel = accountViewModel,
|
||||
navController = navController
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,7 +288,6 @@ fun FastNoteAuthorPicture(
|
||||
val user = userState?.user ?: return
|
||||
|
||||
val showFollowingMark = userAccount.isFollowingCached(user) || user === userAccount
|
||||
|
||||
UserPicture(
|
||||
userHex = user.pubkeyHex,
|
||||
userPicture = user.profilePicture(),
|
||||
|
@ -164,7 +164,15 @@ fun ZapCustomDialog(onClose: () -> Unit, account: Account, accountViewModel: Acc
|
||||
) {
|
||||
OutlinedTextField(
|
||||
// stringResource(R.string.new_amount_in_sats
|
||||
label = { Text(text = stringResource(id = R.string.custom_zaps_add_a_message)) },
|
||||
label = {
|
||||
if (selectedZapType == LnZapEvent.ZapType.PUBLIC || selectedZapType == LnZapEvent.ZapType.ANONYMOUS) {
|
||||
Text(text = stringResource(id = R.string.custom_zaps_add_a_message))
|
||||
} else if (selectedZapType == LnZapEvent.ZapType.PRIVATE) {
|
||||
Text(text = stringResource(id = R.string.custom_zaps_add_a_message_private))
|
||||
} else if (selectedZapType == LnZapEvent.ZapType.NONZAP) {
|
||||
Text(text = stringResource(id = R.string.custom_zaps_add_a_message_nonzap))
|
||||
}
|
||||
},
|
||||
value = postViewModel.customMessage,
|
||||
onValueChange = {
|
||||
postViewModel.customMessage = it
|
||||
|
@ -287,6 +287,9 @@
|
||||
<string name="looking_for_event">"Looking for Event %1$s"</string>
|
||||
|
||||
<string name="custom_zaps_add_a_message">Add a public message</string>
|
||||
<string name="custom_zaps_add_a_message_private">Add a private message</string>
|
||||
<string name="custom_zaps_add_a_message_nonzap">Add an invoice message</string>
|
||||
|
||||
<string name="custom_zaps_add_a_message_example">Thank you for all your work!</string>
|
||||
|
||||
<string name="lightning_create_and_add_invoice">Create and Add</string>
|
||||
|
Loading…
Reference in New Issue
Block a user