mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 22:34:13 +02:00
Requires 10 sat zaps to trigger notifications
This commit is contained in:
@@ -20,6 +20,7 @@ import com.vitorpamplona.quartz.events.LnZapRequestEvent
|
|||||||
import com.vitorpamplona.quartz.events.PrivateDmEvent
|
import com.vitorpamplona.quartz.events.PrivateDmEvent
|
||||||
import com.vitorpamplona.quartz.events.SealedGossipEvent
|
import com.vitorpamplona.quartz.events.SealedGossipEvent
|
||||||
import kotlinx.collections.immutable.persistentSetOf
|
import kotlinx.collections.immutable.persistentSetOf
|
||||||
|
import java.math.BigDecimal
|
||||||
|
|
||||||
class EventNotificationConsumer(private val applicationContext: Context) {
|
class EventNotificationConsumer(private val applicationContext: Context) {
|
||||||
|
|
||||||
@@ -129,15 +130,17 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
private fun notify(event: LnZapEvent) {
|
private fun notify(event: LnZapEvent) {
|
||||||
val noteZapEvent = LocalCache.notes[event.id] ?: return
|
val noteZapEvent = LocalCache.notes[event.id] ?: return
|
||||||
|
|
||||||
val noteZapRequest = event.zapRequest?.id?.let { LocalCache.checkGetOrCreateNote(it) }
|
val noteZapRequest = event.zapRequest?.id?.let { LocalCache.checkGetOrCreateNote(it) } ?: return
|
||||||
val noteZapped = event.zappedPost().firstOrNull()?.let { LocalCache.checkGetOrCreateNote(it) }
|
val noteZapped = event.zappedPost().firstOrNull()?.let { LocalCache.checkGetOrCreateNote(it) }
|
||||||
|
|
||||||
|
if ((event.amount ?: BigDecimal.ZERO) < BigDecimal.TEN) return
|
||||||
|
|
||||||
LocalPreferences.allSavedAccounts().forEach {
|
LocalPreferences.allSavedAccounts().forEach {
|
||||||
val acc = LocalPreferences.loadFromEncryptedStorage(it.npub)
|
val acc = LocalPreferences.loadFromEncryptedStorage(it.npub)
|
||||||
|
|
||||||
if (acc != null && acc.userProfile().pubkeyHex == event.zappedAuthor().firstOrNull()) {
|
if (acc != null && acc.userProfile().pubkeyHex == event.zappedAuthor().firstOrNull()) {
|
||||||
val amount = showAmount(event.amount)
|
val amount = showAmount(event.amount)
|
||||||
val senderInfo = (noteZapRequest?.event as? LnZapRequestEvent)?.let {
|
val senderInfo = (noteZapRequest.event as? LnZapRequestEvent)?.let {
|
||||||
val decryptedContent = acc.decryptZapContentAuthor(noteZapRequest)
|
val decryptedContent = acc.decryptZapContentAuthor(noteZapRequest)
|
||||||
if (decryptedContent != null) {
|
if (decryptedContent != null) {
|
||||||
val author = LocalCache.getOrCreateUser(decryptedContent.pubKey)
|
val author = LocalCache.getOrCreateUser(decryptedContent.pubKey)
|
||||||
|
Reference in New Issue
Block a user