diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt index 68137cd57..653a1fdf6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt @@ -5,6 +5,7 @@ import com.google.gson.JsonElement import com.vitorpamplona.amethyst.BuildConfig import com.vitorpamplona.amethyst.service.model.Event import com.vitorpamplona.amethyst.service.model.EventInterface +import com.vitorpamplona.amethyst.service.model.RelayAuthEvent import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response @@ -119,11 +120,11 @@ class Relay( it.onError(this@Relay, channel, Error("Relay sent notice: " + channel)) } "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) } "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) } else -> listeners.forEach { @@ -234,11 +235,19 @@ class Relay( } fun send(signedEvent: EventInterface) { - if (write) { - val event = """["EVENT",${signedEvent.toJson()}]""" + if (signedEvent is RelayAuthEvent) { + val event = """["AUTH",${signedEvent.toJson()}]""" socket?.send(event) eventUploadCounterInBytes += event.bytesUsedInMemory() } + + if (write) { + if (signedEvent !is RelayAuthEvent) { + val event = """["EVENT",${signedEvent.toJson()}]""" + socket?.send(event) + eventUploadCounterInBytes += event.bytesUsedInMemory() + } + } } fun close(subscriptionId: String) {