Skip to content

Commit

Permalink
Fix app freeze after an error, fix empty queries, add nip 40 and 59 t…
Browse files Browse the repository at this point in the history
…o nip 11 doc
  • Loading branch information
greenart7c3 committed Sep 9, 2024
1 parent 8a507b8 commit 9fec2c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CustomWebSocketServer(
"description": "${Settings.description}",
"pubkey": "${Settings.ownerPubkey}",
"contact": "${Settings.contact}",
"supported_nips": [1,2,4,9,11,45,50],
"supported_nips": [1,2,4,9,11,40,45,50,59],
"software": "https://github.com/greenart7c3/Citrine",
"version": "${BuildConfig.VERSION_NAME}",
"icon": "${Settings.relayIcon}"
Expand All @@ -271,27 +271,30 @@ class CustomWebSocketServer(
connections += thisConnection
try {
for (frame in incoming) {
when (frame) {
is Frame.Text -> {
val message = frame.readText()
processNewRelayMessage(message, thisConnection)
try {
when (frame) {
is Frame.Text -> {
val message = frame.readText()
processNewRelayMessage(message, thisConnection)
}

else -> {
Log.d("error", frame.toString())
send(NoticeResult.invalid("Error processing message").toJson())
}
}
else -> {
Log.d("error", frame.toString())
send(NoticeResult.invalid("Error processing message").toJson())
} catch (e: Throwable) {
if (e is CancellationException) throw e
Log.d("error", e.toString(), e)
try {
if (!thisConnection.session.outgoing.isClosedForSend) {
send(NoticeResult.invalid("Error processing message").toJson())
}
} catch (e: Exception) {
Log.d("error", e.toString(), e)
}
}
}
} catch (e: Throwable) {
if (e is CancellationException) throw e
Log.d("error", e.toString(), e)
try {
if (!thisConnection.session.outgoing.isClosedForSend) {
send(NoticeResult.invalid(closeReason.await()?.message ?: "").toJson())
}
} catch (e: Exception) {
Log.d("error", e.toString(), e)
}
} finally {
Log.d("connection", "Removing ${thisConnection.name}!")
thisConnection.finalize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object EventRepository {
}
}

val predicatesSql = whereClause.joinToString(" AND ", prefix = "WHERE ")
val predicatesSql = if (whereClause.isNotEmpty()) whereClause.joinToString(" AND ", prefix = "WHERE ") else ""

var query = """
SELECT EventEntity.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SubscriptionManager(val subscription: Subscription) {
} catch (e: Exception) {
if (e is CancellationException) throw e

Log.d("error", "Error reading data from database", e)
Log.d("error", "Error reading data from database $filter", e)
subscription.connection.session.send(
NoticeResult.invalid("Error reading data from database").toJson(),
)
Expand Down

0 comments on commit 9fec2c8

Please sign in to comment.