Fixes AUTH NIP42 bug. Amethyst was sending the event as a regular EVENT and not an AUTH command
This commit is contained in:
@@ -5,6 +5,7 @@ import com.google.gson.JsonElement
|
|||||||
import com.vitorpamplona.amethyst.BuildConfig
|
import com.vitorpamplona.amethyst.BuildConfig
|
||||||
import com.vitorpamplona.amethyst.service.model.Event
|
import com.vitorpamplona.amethyst.service.model.Event
|
||||||
import com.vitorpamplona.amethyst.service.model.EventInterface
|
import com.vitorpamplona.amethyst.service.model.EventInterface
|
||||||
|
import com.vitorpamplona.amethyst.service.model.RelayAuthEvent
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
@@ -119,11 +120,11 @@ class Relay(
|
|||||||
it.onError(this@Relay, channel, Error("Relay sent notice: " + channel))
|
it.onError(this@Relay, channel, Error("Relay sent notice: " + channel))
|
||||||
}
|
}
|
||||||
"OK" -> listeners.forEach {
|
"OK" -> listeners.forEach {
|
||||||
// Log.w("Relay", "Relay on OK $url, $channel")
|
// Log.w("Relay", "AUTHSENT Relay on OK $url, ${msg[1].asString}, ${msg[2].asBoolean}, ${msg[3].asString}")
|
||||||
it.onSendResponse(this@Relay, msg[1].asString, msg[2].asBoolean, msg[3].asString)
|
it.onSendResponse(this@Relay, msg[1].asString, msg[2].asBoolean, msg[3].asString)
|
||||||
}
|
}
|
||||||
"AUTH" -> listeners.forEach {
|
"AUTH" -> listeners.forEach {
|
||||||
// Log.w("Relay", "Relay AUTH $url, $channel")
|
// Log.w("Relay", "Relay AUTHSENT $url, ${msg[1].asString}")
|
||||||
it.onAuth(this@Relay, msg[1].asString)
|
it.onAuth(this@Relay, msg[1].asString)
|
||||||
}
|
}
|
||||||
else -> listeners.forEach {
|
else -> listeners.forEach {
|
||||||
@@ -234,12 +235,20 @@ class Relay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun send(signedEvent: EventInterface) {
|
fun send(signedEvent: EventInterface) {
|
||||||
|
if (signedEvent is RelayAuthEvent) {
|
||||||
|
val event = """["AUTH",${signedEvent.toJson()}]"""
|
||||||
|
socket?.send(event)
|
||||||
|
eventUploadCounterInBytes += event.bytesUsedInMemory()
|
||||||
|
}
|
||||||
|
|
||||||
if (write) {
|
if (write) {
|
||||||
|
if (signedEvent !is RelayAuthEvent) {
|
||||||
val event = """["EVENT",${signedEvent.toJson()}]"""
|
val event = """["EVENT",${signedEvent.toJson()}]"""
|
||||||
socket?.send(event)
|
socket?.send(event)
|
||||||
eventUploadCounterInBytes += event.bytesUsedInMemory()
|
eventUploadCounterInBytes += event.bytesUsedInMemory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun close(subscriptionId: String) {
|
fun close(subscriptionId: String) {
|
||||||
socket?.send("""["CLOSE","$subscriptionId"]""")
|
socket?.send("""["CLOSE","$subscriptionId"]""")
|
||||||
|
|||||||
Reference in New Issue
Block a user