Skip to content

Commit

Permalink
Check for empty relays, always use the application relays and not the…
Browse files Browse the repository at this point in the history
… default relays
  • Loading branch information
greenart7c3 committed Jan 24, 2025
1 parent ed41aa2 commit a7d9bd8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ object BunkerRequestUtils {
onLoading: (Boolean) -> Unit,
onDone: (Boolean) -> Unit,
) {
if (relays.isEmpty()) {
onDone(true)
onLoading(false)
NostrSigner.getInstance().applicationIOScope.launch {
relays.forEach { relay ->
NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub()).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
type = "bunker response",
message = "No relays specified for the bunker response",
time = System.currentTimeMillis(),
),
)
}
}

return
}

AmberListenerSingleton.getListener()?.let {
NostrSigner.getInstance().client.unsubscribe(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
acc,
bunkerRequest,
BunkerResponse(bunkerRequest.id, "", message),
applicationWithSecret?.application?.relays ?: NostrSigner.getInstance().getSavedRelays().toList(),
applicationWithSecret?.application?.relays ?: emptyList(),
onLoading = { },
onDone = {
if (!it) {
Expand All @@ -250,7 +250,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
acc,
bunkerRequest,
BunkerResponse(bunkerRequest.id, "", message),
applicationWithSecret?.application?.relays ?: NostrSigner.getInstance().getSavedRelays().toList(),
applicationWithSecret?.application?.relays ?: emptyList(),
onLoading = { },
onDone = { },
)
Expand Down Expand Up @@ -294,7 +294,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
if (type == SignerType.CONNECT) {
message = "$name ${bunkerPermission.toLocalizedString(applicationContext)}"
}
val relays = permission?.application?.relays ?: applicationWithSecret?.application?.relays ?: NostrSigner.getInstance().getSavedRelays().toList()
val relays = permission?.application?.relays ?: applicationWithSecret?.application?.relays ?: emptyList()

if (type == SignerType.INVALID) {
Log.d("EventNotificationConsumer", "Invalid request method ${bunkerRequest.method}")
Expand Down

0 comments on commit a7d9bd8

Please sign in to comment.