kamax-matrix / matrix-java-sdk Goto Github PK
View Code? Open in Web Editor NEWMatrix Java SDK
License: GNU Affero General Public License v3.0
Matrix Java SDK
License: GNU Affero General Public License v3.0
I need support for m.receipt
next:
https://matrix.org/docs/spec/client_server/r0.3.0.html#id57
The method getJoinedUsers
in the class MatrixHttpRoom
currenly only returns a MatrixID. The response also contains the avatar's url and the display name. These two strings should be somehow accessible to the caller, too.
I need to be able to set the device name during login to resolve https://github.com/MrCustomizer/palaver/issues/46.
I think it's the parameter initial_device_display_name
, which probably has to be added to the MatrixClientContext
.
The spec allows the access token to be provided in headers or in query parameter.
We need to support both and leave the option of which to use at the client object creation time.
Headers will be the default option.
please publish it somewhere :)
This is a list of event Types that I currently manually need to match as they don't get parsed to a java type.
Currently it's not possible to query the contents of an event with an image via the API. Image events have next to the body an info JSON-object which contains the necessary information like mimetype information, the mxc-URL of the image etc. It would be nice to be able to query this stuff via the API instead of having to parse the JSON-info object itself.
Room message events can contain formatted text. Several clients also seem to more or less use this feature. Especially Riot makes excessive use of it. I stumbled upon it when learning about the mechanisms of how Riot handles mentions. Mention pills are html link tags, where href follows a certain formatting standard.
Several other html tags for formatting text are also supported.
Long story short: MatrixJsonRoomMessageEvent
should be extended, so that clients are able to access the formatted text body sent by other clients instead of only the raw text body. I propose adding the methods getFormattedBody
and getFormat
to access the JSON fields formatted_body
and format
in the content
object of the event.
I suggest adding a new event which implements MatrixJsonEvent
with the name MatrixJsonRoomTopicEvent
. This event should be a represantation of a timeline event of a room with the type m.room.topic
.
As part of the initial implementation, be able to receive core events from the HS for a very basic usage, in the lines of a bot client which would act on messages from regular users and can navigate rooms.
List events to support:
One of the state events returned when calling sync is the event which contains a room's topic. It would be nice if the SDK's interface could be expanded to query these topics.
The object JoinedRoom
in SyncData
needs a new object to read the unread notifications and highlights. Relevant part of the spec: https://matrix.org/docs/spec/client_server/r0.3.0.html#get-matrix-client-r0-sync
HttpRequests need three timeouts to be set, so that the requests automatically return on a bad connection. The default for these timeouts sadly is "infinity". The timeouts can be set like this:
int timeout = <suitableTimeout>
RequestConfig.Builder configBuilder = request.getConfig().custom();
if (request.getConfig() != null) {
configBuilder = RequestConfig.copy(request.getConfig());
}
configBuilder.setConnectionRequestTimeout(timeout);
configBuilder.setConnectTimeout(timeout);
configBuilder.setSocketTimeout(timeout);
httpRequest.setConfig(configBuilder.build());
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
at com.google.gson.Gson.fromJson(Gson.java:887)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.google.gson.Gson.fromJson(Gson.java:773)
at io.kamax.matrix.client.AMatrixHttpClient.createErrorInfo(AMatrixHttpClient.java:312)
at io.kamax.matrix.client.AMatrixHttpClient.execute(AMatrixHttpClient.java:202)
at io.kamax.matrix.client.AMatrixHttpClient.execute(AMatrixHttpClient.java:186)
at io.kamax.matrix.client.regular.MatrixHttpClient.sync(MatrixHttpClient.java:159)
at io.kamax.matrix.bots.send_n_leave.SendNLeaveBot.lambda$start$6(SendNLeaveBot.java:94)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213)
... 10 more
Androids new D8 Dex merger does complain if building the sdk sometimes :/
Error I get is:
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): void io.kamax.matrix.hs._MatrixRoom.sendReadReceipt(java.lang.String)","sources":[{}],"tool":"D8"}
MatrixJsonRoomMembershipEvent
has to be extended, so that it is possible to query the membership parameter of the JSON object. According to the spec it can contain the following values: "invite", "join", "knock", "leave" and "ban".
I would like to be able to query a room's avatar. The SDK has to support the endpoint m.room.avatar for that.
Exception message is: Unable to invoke no-args constructor for interface io.kamax.matrix._MatrixID. Registering an InstanceCreator with Gson for this type may fix this problem.
Related to https://sentry.io/share/issue/83ef2528d719440fac33341327d36002/
The MatrixErrorInfo class should make the server response Json object accessible (if available).
For example, when encountering an error because of rate-limiting, the response informs the client, when it may retry. This information is necessary for well behaving clients.
See https://matrix.org/docs/spec/client_server/r0.4.0.html#rate-limiting
_SyncData contains the types InvitedRoom
, JoinedRoom
and LeftRoom
. Currently they don't have a generalized type. This leads to code duplication and in some cases triplication.
All three types contain synchronisation data for a specific room. Common properties are the room ID #getId()
and the state events #getState()
.
A generalized type RoomData
(or some other name) could be
interface RoomData {
String getId(); // room ID
State getState(); // state events
}
For better distinction between the RoomData
subtypes add a RoomDataKind
enum
enum RoomDataKind {
JOINED,
INVITED,
LEFT
;
}
interface RoomData {
…
RoomDataKind getKind();
}
There is currently no official way in the spec to discover the client endpoint for a given Matrix domain, which would be the equivalent of the SRV record for the S2S API.
Following several conversations and exchanges [1] [2], we'll use a .well-known
URL [RFC 5785].
For the domain example.org
, the discovery URL will be: https://example.org/.well-known/matrix
It will return a status code 200 and body as JSON object like so:
{
"m.hs": {
"base_urls": [
"https://a.mxhsd.example.org",
"https://b.mxhsd.example.org",
"https://c.mxhsd.example.org/with/prefix/path",
"https://d.mxhsd.example.org:12345"
]
},
"m.is": {
"base_urls": [
"https://a.mxisd.example.org",
"https://b.mxisd.example.org",
"https://c.mxisd.example.org/with/prefix/path",
"https://d.mxisd.example.org:12345"
]
},
"im.vector.riot.integrations": {
"ui_url": "https://dimension.example.org/riot",
"rest_url": "https://dimension.example.org/api/v1/scalar",
"widgets_urls": [
"https://dimension.example.org/widgets"
]
}
}
For base_urls
in m.hs
and m.is
:
/_matrix/...
path.m.hs
, /_matrix/client/versions
is reachable and contains valid datam.is
, /_matrix/identity/versions
is reachable and contains valid dataEvery other entry will be DNS namespace, like other parts of the Matrix protocol, so custom features in clients can also receive dedicated configuration, or rely on other other clients supported configuration.
In this case, im.vector.riot.integrations
would reference to the Riot Integration Manager and any other client that supports it.
/_matrix/identity/versions
will be defined at https://kamax.io/matrix/api/identity_service/unstable.html
This implementation will be documented at https://kamax.io/matrix/api/client_server/unstable.html
Some event types are missing:
m.room.guest_access
m.room.join_rules
m.room.redaction
Add support for setting the user avatar image.
See https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-profile-userid-avatar-url
There is a currently a method defined for uploading files and specifying the content-type:
MatrixHttpClient.putMedia(File data, String type)
.
There should be an additional method which accepts a filename parameter:
MatrixHttpClient.putMedia(File data, String type, String filename)
The specification defines the URL query parameter filename
.
See https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-media-r0-upload
The m.room.message with message type m.image specifies only the name that is displayed. However when downloading a file, the matrix client gets a random filename such as AgTxPeyqwuCUpoyPjAgBcVxH.png
Full Stacktrace: https://sentry.io/share/issue/80ab39b6f90b43d79a5828e179c77b87/
This happened on login in SimpleMatrix with Android 6.0.1
java.lang.NullPointerException
at io.kamax.matrix.client.AMatrixHttpClient.extractAsStringFromBody(AMatrixHttpClient.java:317)
at io.kamax.matrix.client.MatrixHttpUser.getName(MatrixHttpUser.java:62)
at de.localtoast.palaver.sys.RoomRepository.fetchRoomName(RoomRepository.kt:87)
at de.localtoast.palaver.sys.RoomRepository.prefetch(RoomRepository.kt:95)
at de.localtoast.palaver.sys.events.MatrixEventProcessor.prefetch(MatrixEventProcessor.kt:99)
at de.localtoast.palaver.sys.events.MatrixEventProcessor.access$prefetch(MatrixEventProcessor.kt:35)
at de.localtoast.palaver.sys.events.MatrixEventProcessor$processNewEventsForRoom$1.invoke(MatrixEventProcessor.kt:84)
at de.localtoast.palaver.sys.events.MatrixEventProcessor$processNewEventsForRoom$1.invoke(MatrixEventProcessor.kt:35)
at tornadofx.FXTask.call(Async.kt:416)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Describe how to perform basic actions with the SDK:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.