diff --git a/matrix/services/message/src/main/kotlin/app/dapk/st/matrix/message/internal/SendMessageUseCase.kt b/matrix/services/message/src/main/kotlin/app/dapk/st/matrix/message/internal/SendMessageUseCase.kt index 4dbfa5e..c5e52be 100644 --- a/matrix/services/message/src/main/kotlin/app/dapk/st/matrix/message/internal/SendMessageUseCase.kt +++ b/matrix/services/message/src/main/kotlin/app/dapk/st/matrix/message/internal/SendMessageUseCase.kt @@ -66,7 +66,6 @@ internal class SendMessageUseCase( true -> { val result = mediaEncrypter.encrypt(imageContent.inputStream()) val bytes = File(result.uri).readBytes() - println("!!! ${bytes.size}") val uri = httpClient.execute(uploadRequest(bytes, imageContent.fileName, "application/octet-stream")).contentUri @@ -114,9 +113,7 @@ internal class SendMessageUseCase( } false -> { - val bytes = ByteArrayOutputStream().also { - it.writeTo(imageContent.outputStream()) - }.toByteArray() + val bytes = File(imageContent.uri).readBytes() val uri = httpClient.execute(uploadRequest(bytes, imageContent.fileName, imageContent.mimeType)).contentUri sendRequest( diff --git a/test-harness/src/test/kotlin/SmokeTest.kt b/test-harness/src/test/kotlin/SmokeTest.kt index 8779851..87be394 100644 --- a/test-harness/src/test/kotlin/SmokeTest.kt +++ b/test-harness/src/test/kotlin/SmokeTest.kt @@ -71,18 +71,18 @@ class SmokeTest { @Order(5) fun `can send and receive encrypted text messages`() = testTextMessaging(isEncrypted = true) -// @Test -// @Order(6) -// fun `can send and receive clear image messages`() = testAfterInitialSync { alice, bob -> -// val testImage = loadResourceFile("test-image.png") -// alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = false) -// bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember, isEncrypted = false) -// } + @Test + @Order(6) + fun `can send and receive clear image messages`() = testAfterInitialSync { alice, bob -> + val testImage = loadResourceFile("test-image.png") + alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = false) + bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember) + } @Test @Order(7) fun `can send and receive encrypted image messages`() = testAfterInitialSync { alice, bob -> - val testImage = loadResourceFile("test-image.png") + val testImage = loadResourceFile("test-image2.png") alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = true) bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember) } diff --git a/test-harness/src/test/kotlin/test/Test.kt b/test-harness/src/test/kotlin/test/Test.kt index 562a863..08b4e4c 100644 --- a/test-harness/src/test/kotlin/test/Test.kt +++ b/test-harness/src/test/kotlin/test/Test.kt @@ -147,7 +147,6 @@ class MatrixTestScope(private val testScope: TestScope) { this.client.syncService().room(roomId) .map { it.events.filterIsInstance().map { - println("found: ${it}") val output = File(image.parentFile.absolutePath, "output.png") HttpClient().request(it.imageMeta.url).bodyAsChannel().copyAndClose(output.writeChannel()) val md5Hash = when (val keys = it.imageMeta.keys) { diff --git a/test-harness/src/test/resources/test-image2.png b/test-harness/src/test/resources/test-image2.png new file mode 100644 index 0000000..56b0161 Binary files /dev/null and b/test-harness/src/test/resources/test-image2.png differ