This repository was archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Remove uses of JsonObject in client server API #6
Copy link
Copy link
Open
Description
Some endpoints like SendMessage take a JsonObject which is less that ideal.
| public class SendMessage( | |
| public override val url: Url, | |
| public override val body: JsonObject | |
| ) : MatrixRpc.WithAuth<RpcMethod.Put, SendMessage.Url, JsonObject, SendMessage.Response> { |
To send messages one has to do this, which is rather verbose and forces one to specify MatrixJson which can break some abstractions.
SendMessage(
SendMessage.Url(roomId, "m.room.message", txnId),
MatrixJson.encodeToJsonElement<MessageContent>(MessageContent.Text("test body")).jsonObject
)It had to be done this way since KTor just didn't support it. Request bodies underwent type erasure.
However this has been fixed in KTor 2.0.0 and so we can now use generics.
Fixing this issue means allowing this to be possible.
SendMessage<MessageContent>(
SendMessage.Url(roomId, "m.room.message", txnId),
MessageContent.Text("test body")
)In some cases the generic parameter need to be a JSON object and not an array, string, etc.
There isn't an idiomatic way to prevent the user from being naughty here so I'll leave it to the user to behave. This library shouldn't be jumping through hoops to hand hold the user.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels