Merge branch 'main' of github.com:ouchadam/helium

This commit is contained in:
Adam Brown 2022-09-29 17:42:39 +01:00
commit 7b2f9532b1
2 changed files with 10 additions and 15 deletions

View File

@ -45,6 +45,7 @@ sealed class ApiMessage {
data class Info( data class Info(
@SerialName("h") val height: Int, @SerialName("h") val height: Int,
@SerialName("w") val width: Int, @SerialName("w") val width: Int,
@SerialName("mimetype") val mimeType: String,
@SerialName("size") val size: Long, @SerialName("size") val size: Long,
) )

View File

@ -1,6 +1,9 @@
package app.dapk.st.matrix.message.internal package app.dapk.st.matrix.message.internal
import app.dapk.st.matrix.common.* import app.dapk.st.matrix.common.EventId
import app.dapk.st.matrix.common.EventType
import app.dapk.st.matrix.common.JsonString
import app.dapk.st.matrix.common.RoomId
import app.dapk.st.matrix.http.MatrixHttpClient import app.dapk.st.matrix.http.MatrixHttpClient
import app.dapk.st.matrix.http.MatrixHttpClient.HttpRequest import app.dapk.st.matrix.http.MatrixHttpClient.HttpRequest
import app.dapk.st.matrix.message.ApiSendResponse import app.dapk.st.matrix.message.ApiSendResponse
@ -57,7 +60,7 @@ internal class SendMessageUseCase(
} }
} }
private suspend fun ApiMessageMapper.imageMessageRequest(message: Message.ImageMessage): HttpRequest<ApiSendResponse> { private suspend fun imageMessageRequest(message: Message.ImageMessage): HttpRequest<ApiSendResponse> {
val imageMeta = imageContentReader.meta(message.content.uri) val imageMeta = imageContentReader.meta(message.content.uri)
return when (message.sendEncrypted) { return when (message.sendEncrypted) {
@ -91,11 +94,11 @@ internal class SendMessageUseCase(
info = ApiMessage.ImageMessage.ImageContent.Info( info = ApiMessage.ImageMessage.ImageContent.Info(
height = imageMeta.height, height = imageMeta.height,
width = imageMeta.width, width = imageMeta.width,
size = imageMeta.size size = imageMeta.size,
mimeType = imageMeta.mimeType,
) )
) )
val json = JsonString( val json = JsonString(
MatrixHttpClient.jsonWithDefaults.encodeToString( MatrixHttpClient.jsonWithDefaults.encodeToString(
ApiMessage.ImageMessage.serializer(), ApiMessage.ImageMessage.serializer(),
@ -134,7 +137,8 @@ internal class SendMessageUseCase(
ApiMessage.ImageMessage.ImageContent.Info( ApiMessage.ImageMessage.ImageContent.Info(
height = imageMeta.height, height = imageMeta.height,
width = imageMeta.width, width = imageMeta.width,
size = imageMeta.size size = imageMeta.size,
mimeType = imageMeta.mimeType,
) )
), ),
) )
@ -163,14 +167,4 @@ class ApiMessageMapper {
) )
) )
fun Message.ImageMessage.toContents(uri: MxUrl, image: ImageContentReader.ImageContent) = ApiMessage.ImageMessage.ImageContent(
url = uri,
filename = image.fileName,
ApiMessage.ImageMessage.ImageContent.Info(
height = image.height,
width = image.width,
size = image.size
)
)
} }