mirror of
				https://github.com/oxen-io/session-android.git
				synced 2025-10-31 16:59:52 +00:00 
			
		
		
		
	fix: 421 errors not being handled properly by sendOnionRequest and prevent retrying with stale swarm data, no longer crash with large NotifyPNServerJob.kt payload in Kryo deserialization
This commit is contained in:
		| @@ -7,6 +7,7 @@ import nl.komponents.kovenant.functional.map | ||||
| import okhttp3.MediaType | ||||
| import okhttp3.Request | ||||
| import okhttp3.RequestBody | ||||
| import org.session.libsession.messaging.jobs.Job.Companion.MAX_BUFFER_SIZE | ||||
|  | ||||
| import org.session.libsession.messaging.sending_receiving.notifications.PushNotificationAPI | ||||
| import org.session.libsession.messaging.utilities.Data | ||||
| @@ -64,7 +65,7 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job { | ||||
|         val kryo = Kryo() | ||||
|         kryo.isRegistrationRequired = false | ||||
|         val serializedMessage = ByteArray(4096) | ||||
|         val output = Output(serializedMessage) | ||||
|         val output = Output(serializedMessage, MAX_BUFFER_SIZE) | ||||
|         kryo.writeObject(output, message) | ||||
|         output.close() | ||||
|         return Data.Builder() | ||||
|   | ||||
| @@ -433,11 +433,12 @@ object OnionRequestAPI { | ||||
|     internal fun sendOnionRequest(method: Snode.Method, parameters: Map<*, *>, snode: Snode, publicKey: String? = null): Promise<Map<*, *>, Exception> { | ||||
|         val payload = mapOf( "method" to method.rawValue, "params" to parameters ) | ||||
|         return sendOnionRequest(Destination.Snode(snode), payload).recover { exception -> | ||||
|             val httpRequestFailedException = exception as? HTTP.HTTPRequestFailedException | ||||
|             if (httpRequestFailedException != null) { | ||||
|                 val error = SnodeAPI.handleSnodeError(httpRequestFailedException.statusCode, httpRequestFailedException.json, snode, publicKey) | ||||
|                 if (error != null) { throw error } | ||||
|             val error = when (exception) { | ||||
|                 is HTTP.HTTPRequestFailedException -> SnodeAPI.handleSnodeError(exception.statusCode, exception.json, snode, publicKey) | ||||
|                 is HTTPRequestFailedAtDestinationException -> SnodeAPI.handleSnodeError(exception.statusCode, exception.json, snode, publicKey) | ||||
|                 else -> null | ||||
|             } | ||||
|             if (error != null) { throw error } | ||||
|             throw exception | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -290,9 +290,7 @@ object SnodeAPI { | ||||
|             getTargetSnodes(destination).map { swarm -> | ||||
|                 swarm.map { snode -> | ||||
|                     val parameters = message.toJSON() | ||||
|                     retryIfNeeded(maxRetryCount) { | ||||
|                         invoke(Snode.Method.SendMessage, snode, destination, parameters) | ||||
|                     } | ||||
|                     invoke(Snode.Method.SendMessage, snode, destination, parameters) | ||||
|                 }.toSet() | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jubb
					jubb