mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-05 21:52:52 +02:00
Fix for notifications when using amber
This commit is contained in:
@@ -24,6 +24,7 @@ import android.app.NotificationManager
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
import com.vitorpamplona.amethyst.LocalPreferences
|
import com.vitorpamplona.amethyst.LocalPreferences
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.AccountSettings
|
import com.vitorpamplona.amethyst.model.AccountSettings
|
||||||
@@ -42,6 +43,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 com.vitorpamplona.quartz.signers.NostrSigner
|
import com.vitorpamplona.quartz.signers.NostrSigner
|
||||||
|
import com.vitorpamplona.quartz.signers.NostrSignerExternal
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
import kotlin.coroutines.cancellation.CancellationException
|
import kotlin.coroutines.cancellation.CancellationException
|
||||||
@@ -84,6 +86,12 @@ class EventNotificationConsumer(
|
|||||||
// TODO: Modify the external launcher to launch as different users.
|
// TODO: Modify the external launcher to launch as different users.
|
||||||
// Right now it only registers if Amber has already approved this signature
|
// Right now it only registers if Amber has already approved this signature
|
||||||
val signer = account.createSigner()
|
val signer = account.createSigner()
|
||||||
|
if (signer is NostrSignerExternal) {
|
||||||
|
signer.launcher.registerLauncher(
|
||||||
|
launcher = { },
|
||||||
|
contentResolver = Amethyst.instance::contentResolverFn,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pushWrappedEvent.unwrapThrowing(signer) { notificationEvent ->
|
pushWrappedEvent.unwrapThrowing(signer) { notificationEvent ->
|
||||||
val consumed = LocalCache.hasConsumed(notificationEvent)
|
val consumed = LocalCache.hasConsumed(notificationEvent)
|
||||||
|
@@ -22,11 +22,13 @@ package com.vitorpamplona.amethyst.service.notifications
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.vitorpamplona.amethyst.AccountInfo
|
import com.vitorpamplona.amethyst.AccountInfo
|
||||||
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
import com.vitorpamplona.amethyst.BuildConfig
|
import com.vitorpamplona.amethyst.BuildConfig
|
||||||
import com.vitorpamplona.amethyst.LocalPreferences
|
import com.vitorpamplona.amethyst.LocalPreferences
|
||||||
import com.vitorpamplona.amethyst.model.AccountSettings
|
import com.vitorpamplona.amethyst.model.AccountSettings
|
||||||
import com.vitorpamplona.ammolite.service.HttpClientManager
|
import com.vitorpamplona.ammolite.service.HttpClientManager
|
||||||
import com.vitorpamplona.quartz.events.RelayAuthEvent
|
import com.vitorpamplona.quartz.events.RelayAuthEvent
|
||||||
|
import com.vitorpamplona.quartz.signers.NostrSignerExternal
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
@@ -71,6 +73,12 @@ class RegisterAccounts(
|
|||||||
val signer = accountRelayPair.first.createSigner()
|
val signer = accountRelayPair.first.createSigner()
|
||||||
// TODO: Modify the external launcher to launch as different users.
|
// TODO: Modify the external launcher to launch as different users.
|
||||||
// Right now it only registers if Amber has already approved this signature
|
// Right now it only registers if Amber has already approved this signature
|
||||||
|
if (signer is NostrSignerExternal) {
|
||||||
|
signer.launcher.registerLauncher(
|
||||||
|
launcher = { },
|
||||||
|
contentResolver = Amethyst.instance::contentResolverFn,
|
||||||
|
)
|
||||||
|
}
|
||||||
RelayAuthEvent.create(accountRelayPair.second, notificationToken, signer) { result ->
|
RelayAuthEvent.create(accountRelayPair.second, notificationToken, signer) { result ->
|
||||||
continuation.resume(result)
|
continuation.resume(result)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user