Merge pull request #1128 from vector-im/feature/remove_runblocking_crypto
Remove dangerous runBlocking (and un-needed)
This commit is contained in:
		
						commit
						d9085b1231
					
				| @ -627,9 +627,7 @@ internal class DefaultCryptoService @Inject constructor( | |||||||
|      */ |      */ | ||||||
|     @Throws(MXCryptoError::class) |     @Throws(MXCryptoError::class) | ||||||
|     override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { |     override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { | ||||||
|         return runBlocking { |        return internalDecryptEvent(event, timeline) | ||||||
|             internalDecryptEvent(event, timeline) |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -657,7 +655,7 @@ internal class DefaultCryptoService @Inject constructor( | |||||||
|      * @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack. |      * @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack. | ||||||
|      * @return the MXEventDecryptionResult data, or null in case of error |      * @return the MXEventDecryptionResult data, or null in case of error | ||||||
|      */ |      */ | ||||||
|     private suspend fun internalDecryptEvent(event: Event, timeline: String): MXEventDecryptionResult { |     private fun internalDecryptEvent(event: Event, timeline: String): MXEventDecryptionResult { | ||||||
|         val eventContent = event.content |         val eventContent = event.content | ||||||
|         if (eventContent == null) { |         if (eventContent == null) { | ||||||
|             Timber.e("## decryptEvent : empty event content") |             Timber.e("## decryptEvent : empty event content") | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ internal interface IMXDecrypting { | |||||||
|      * @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack. |      * @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack. | ||||||
|      * @return the decryption information, or an error |      * @return the decryption information, or an error | ||||||
|      */ |      */ | ||||||
|     suspend fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult |     fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Handle a key event. |      * Handle a key event. | ||||||
|  | |||||||
| @ -63,7 +63,7 @@ internal class MXMegolmDecryption(private val userId: String, | |||||||
|      */ |      */ | ||||||
|     private var pendingEvents: MutableMap<String /* senderKey|sessionId */, MutableMap<String /* timelineId */, MutableList<Event>>> = HashMap() |     private var pendingEvents: MutableMap<String /* senderKey|sessionId */, MutableMap<String /* timelineId */, MutableList<Event>>> = HashMap() | ||||||
| 
 | 
 | ||||||
|     override suspend fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { |     override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { | ||||||
|         // If cross signing is enabled, we don't send request until the keys are trusted |         // If cross signing is enabled, we don't send request until the keys are trusted | ||||||
|         // There could be a race effect here when xsigning is enabled, we should ensure that keys was downloaded once |         // There could be a race effect here when xsigning is enabled, we should ensure that keys was downloaded once | ||||||
|         val requestOnFail = cryptoStore.getMyCrossSigningInfo()?.isTrusted() == true |         val requestOnFail = cryptoStore.getMyCrossSigningInfo()?.isTrusted() == true | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ internal class MXOlmDecryption( | |||||||
|         private val userId: String) |         private val userId: String) | ||||||
|     : IMXDecrypting { |     : IMXDecrypting { | ||||||
| 
 | 
 | ||||||
|     override suspend fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { |     override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { | ||||||
|         val olmEventContent = event.content.toModel<OlmEventContent>() ?: run { |         val olmEventContent = event.content.toModel<OlmEventContent>() ?: run { | ||||||
|             Timber.e("## decryptEvent() : bad event format") |             Timber.e("## decryptEvent() : bad event format") | ||||||
|             throw MXCryptoError.Base(MXCryptoError.ErrorType.BAD_EVENT_FORMAT, |             throw MXCryptoError.Base(MXCryptoError.ErrorType.BAD_EVENT_FORMAT, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user