GithubHelp home page GithubHelp logo

jmsdk's People

Contributors

blakehawkins avatar brevilo avatar darkiboi avatar ma1uta avatar mikkcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jmsdk's Issues

edit the posted message api

Hi,I can not find the edit the posted mesage api. It need to set the m.relates.to rel_type is "m.replace".I can not find the api to set this filed.
image

ObjectMapper configuration for json serialization

mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

I replace mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); with mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

I use my own http client with the mapper and the jeon model class
and with /_matrix/client/r0/keys/query, i had a bad request with NON_EMPTY because the serialization removes my empty list:

The Java object:

QueryRequest keysQuery = new QueryRequest(); keysQuery.setTimeout(5000L); Map<String, List<String>> devicesKeysRequest = new HashMap<>(); devicesKeysRequest.put(bobLogin.getUserId(), Collections.emptyList()); keysQuery.setDeviceKeys(devicesKeysRequest);

Serialized Json with NON_EMPTY => bad request:
{"timeout":5000}

Serialized Json with NON_NULL => good request:
{"timeout":5000,"device_keys":{"@a66bf63f-d9bc-41d1-99ce-467c2af61c26:matrix.docker.localhost":[]}}

In Matrix spec for /_matrix/client/r0/keys/query:
device_keys : {string: [string]} | Required. The keys to be downloaded. A map from user ID, to a list of device IDs, or to an empty list to indicate all devices for the corresponding user.

SNAPHOST dependency versions in released POMs

When I try to use your library as Maven dependency in the latest version 0.10.0, there are bunch of unresolvable transitive dependencies of version 0.9.2-SNAPSHOT. I noticed in your POM you are using dedicated version properties and you probably forgot to bump them.

What I recommend it to keep the version on a single place (the top most parent POM) and refer to that version. I will create a PR for both jmsdk and jeon repositories.

Bump dependencies and new release?

Hi!

Development seems to be paused right now. Could you please consider bumping the dependencies again and push another release so that the latest version is available via maven?

Thanks and keep it up!

[Docs] Missing example for inbound event handler at client-impl

Hello

I am trying to figure out on how to get, identify and handle events. I copied your example, but it is missing clarification on how to work with events. Please add some documentation on readme.md or an example class.

SyncLoop syncLoop = new SyncLoop(mxClient.sync(), (syncResponse, syncParams) -> {
//Get event
//Check event type (User joined room)
//Get user and send invitations
});

SyncParams params = SyncParams.builder()
.fullState(false)
.presence(null)
.timeout(1000L)
.build();
syncLoop.setInit(params);
ExecutorService service = Executors.newFixedThreadPool(1);
service.submit(syncLoop);

syncloop can spew io.github.ma1uta.matrix.impl.exception.MatrixException: User-interactive response "null" after improper shutdown

If you enable a SyncLoop and then shut down or log out your client before shutting down your SyncLoop, it will start spewing an exception:

12:18:51.850 [pool-3-thread-1] ERROR io.github.ma1uta.matrix.client.filter.ErrorFilter - User-interactive response, session: null
12:18:51.851 [pool-3-thread-1] ERROR io.github.ma1uta.matrix.client.filter.ErrorFilter - Response: {"errcode":"M_MISSING_TOKEN","error":"Missing access token"}
12:18:51.860 [pool-3-thread-1] ERROR io.github.ma1uta.matrix.client.filter.ErrorFilter - Unable to invoke request
io.github.ma1uta.matrix.impl.exception.MatrixException: User-interactive response "null"
        at io.github.ma1uta.matrix.client.filter.ErrorFilter.throwUserInteractiveException(ErrorFilter.java:79)
        at io.github.ma1uta.matrix.client.filter.ErrorFilter.filter(ErrorFilter.java:60)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.filterResponse(ClientInvocation.java:711)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:489)
        at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invokeSync(ClientInvoker.java:149)
        at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:112)
        at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
        at com.sun.proxy.$Proxy34.sync(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.microprofile.client.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:164)
        at com.sun.proxy.$Proxy35.sync(Unknown Source)
        at io.github.ma1uta.matrix.client.methods.blocked.SyncMethods.sync(SyncMethods.java:47)
        at io.github.ma1uta.matrix.client.sync.SyncLoop.run(SyncLoop.java:64)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

There are a number of minor changes that can be made to make this interaction a bit safer and make this failure mode more difficult to hit:

  • client logout is non-blocking
  • syncloop docs should recommend blocking on executor shutdown finished
  • thread interruption should be sufficient for syncloop to terminate
  • it should be possible to query a client for its connected status

jitpack.io integration: build failures

Hello,

This project looks great -- I'd like to incorporate it in a larger project I'm working on, called Manebot. It's a project where I'm trying to aggregate the functionality of various chat platform APIs (Discord, etc.) into a single framework where people can write plugins that work on all of them at once.

This project is extremely promising, and I'd really like to build https://github.com/Manebot/matrix on top of it. I'm working on integrating it with my ecosystem, but I noticed that Jitpack can't build this due to the fact that the packages here are not quite right for https://github.com/ma1uta/jeon:

Jeon is under:

<groupId>io.github.ma1uta.matrix</groupId>

While jitpack.io would require:

<groupId>io.github.ma1uta.jeon</groupId>

I'm wondering if you could present jmsdk & jeon under different groups so that they can be linked by Jitpack.io. It also might make more sense from an organization standpoint.

Here's the build on jitpack.io that fails. If you open this link later on, you might need to wait for Jitpack to build it first (it has retries):

https://jitpack.io/com/github/ma1uta/jmsdk/ee09a3b86a/build.log

The specific error I'm noticing is,

[ERROR] Failed to execute goal on project common-impl: Could not resolve dependencies for project io.github.ma1uta.matrix:common-impl:jar:0.9.2-SNAPSHOT: Could not find artifact io.github.ma1uta.matrix:common-api:jar:0.9.2-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :common-impl

Aside from the packages, it may be necessary to also add their repository:

        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>

If that's not something you'd like to add to your pom.xml, I think it might work without it, and Jitpack.io might already have those in its own repositories when it builds. So, it may not be needed.

Thank-you! I look forward to building something cool on this project.

jsonb-support: module not found: java.json

Module hell strikes again. I get this when compiling (latest master) with Java 11 and an empty maven repo:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project jsonb-support: Compilation failure
[ERROR] jsonb-support/src/main/java/module-info.java:[29,29] module not found: java.json

Support for end-to-end encryption

Hi, I am sorry to use the issue for that, but how can I decipher messages went I have a RoomEncryptedContent instance ?

Does the sdk provides a way to do that ?

Cached RestClientBuilder generates warnings

Based on v0.11.3:

I'm constantly getting warnings messages about duplicate registrations in RestEasy.

19:07:58.080 [main            ] WARN  o.jboss.resteasy.resteasy_jaxrs.i18n RESTEASY002160: Provider instance org.jboss.resteasy.microprofile.client.DefaultResponseExceptionMapper is already registered.  2nd registration is being ignored.
19:08:01.050 [main            ] WARN  o.jboss.resteasy.resteasy_jaxrs.i18n RESTEASY002160: Provider instance org.jboss.resteasy.microprofile.client.ExceptionMapping is already registered.  2nd registration is being ignored.
19:08:02.181 [main            ] WARN  o.jboss.resteasy.resteasy_jaxrs.i18n RESTEASY002160: Provider instance org.jboss.resteasy.microprofile.client.DefaultMediaTypeFilter is already registered.  2nd registration is being ignored.

These occur every time I ask for a MatrixClient.XXX() (ie. sync(), rooms(), clientConfig(), etc.). As far as I can tell, this is because each of those gets the same RestClientBuilder (since it's cached), but builds a new RestClient for the specific API interface.

Unfortunately, RestEasy seems to then go ahead and register a bunch of objects into the client, and since they've been registered by one of the previous ones, it fails.

I haven't tried fixing it, but maybe removing the caching at:

and just build a new one for each API?

I understand that I can just adjust the logging engine to drop these warnings, but I'm always nervous about ignoring too much and losing a meaningful warning.

ERROR i.g.m.m.c.AbstractHomeServerResolver - Wrong url: https://<homeserver>//_matrix/client/versions

Hello, we are trying to install Synapse on our own server. (synapse)

You can see here that it add "/" at the end of public_baseurl.

When we are trying to connect to our server through your SDK it throws exeptions
ERROR i.g.m.m.c.AbstractHomeServerResolver - Wrong url: https://<homeserver>//_matrix/client/versions. Here is a Malformed URL.

Seems like here response.getHomeserver() returns homeserver with "/" at the end. And here you are adding another "/" with "/_matrix/client/versions". Is there a way to fix this?

Deserialisation Error RoomPowerLevels

Hi, I am getting following error during the roomState request:

com.fasterxml.jackson.databind.JsonMappingException: Numeric value (9001) out of range of Java byte
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: io.github.ma1uta.matrix.event.RoomPowerLevels["content"]->io.github.ma1uta.matrix.event.content.RoomPowerLevelsContent["users"])

It doesn't bother me as I don't need that value, I just wanted to let you know.

versions:
client-impl: 0.13.1
microprofile-rest-client-api: 2.0.1-RC1
jackson-databind: 2.9.8

rooms().invite(roomId, InviteRequest) fails for mxId requests

Based on a reading of the Matrix spec, invite can support either local IDs or third-party IDs:
https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-rooms-roomid-invite

However, in this code path:
https://github.com/ma1uta/jmsdk/blob/master/client-impl/src/main/java/io/github/ma1uta/matrix/client/methods/blocked/RoomMethods.java#L117-L120

The client asserts that all input is set.

Can this validation be relaxed to only require userId?

43 test failures

Using mvn clean install on the latest 0.14.0 snapshot version, I got a lot of test failures:

[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.051 s <<< FAILURE! - in io.github.ma1uta.matrix.client.VoipAsyncMethodsTest
[ERROR] io.github.ma1uta.matrix.client.VoipAsyncMethodsTest.voip  Time elapsed: 0.036 s  <<< ERROR!
com.github.tomakehurst.wiremock.common.FatalStartupException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
Caused by: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
Caused by: java.net.BindException: Address already in use: bind
[ERROR] io.github.ma1uta.matrix.client.VoipAsyncMethodsTest.secured  Time elapsed: 0.015 s  <<< ERROR!
com.github.tomakehurst.wiremock.common.FatalStartupException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
Caused by: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
Caused by: java.net.BindException: Address already in use: bind
[ERROR] Failures:
[ERROR]   HomeServerResolverTest.wellKnownTest:36 expected: <https://ru-matrix.org:8448> but was: <https://ru-matrix.org>
[ERROR] Errors:
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.shutdown:47 » Runtime com.fasterxml.jackson...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AccountAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   AdminAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeExce...
[ERROR]   AuthMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeException:...
[ERROR]   AuthMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeException:...
[ERROR]   AuthMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeException:...
[ERROR]   AuthMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeException:...
[ERROR]   AuthMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeException:...
[ERROR]   AuthMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeException:...
[ERROR]   ClientConfigAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.Runt...
[ERROR]   ClientConfigAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.Runt...
[ERROR]   ClientConfigAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.Runt...
[ERROR]   ClientConfigAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.Runt...
[ERROR]   ContentAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   VersionAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeEx...
[ERROR]   VoipAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeExcep...
[ERROR]   VoipAsyncMethodsTest>MockServer.setUp:42 » FatalStartup java.lang.RuntimeExcep...
[INFO]
[ERROR] Tests run: 43, Failures: 1, Errors: 40, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] jmsdk 0.14.0-SNAPSHOT .............................. SUCCESS [  2.034 s]
[INFO] Jeon BOM 0.14.0-SNAPSHOT ........................... SUCCESS [  0.214 s]
[INFO] common-impl 0.14.0-SNAPSHOT ........................ SUCCESS [  3.899 s]
[INFO] jackson-support 0.14.0-SNAPSHOT .................... SUCCESS [  5.747 s]
[INFO] client-impl 0.14.0-SNAPSHOT ........................ FAILURE [ 10.116 s]
[INFO] bot-impl 0.14.0-SNAPSHOT ........................... SKIPPED
[INFO] jsonb-support 0.14.0-SNAPSHOT ...................... SKIPPED
[INFO] simple 1.0-SNAPSHOT ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Collaboration

Hi, ma1uta!

My name is Segey, and I'm reaching out to you, because of your work on matrix clients

I'm currently working on an implementation of hyper-local (firechat style) chats and I want to make it on matrix platform.

This far I have successfully ported mdns from libp2p to android and have a working solution, but, since I'm not a very experienced developer on java, I need to someone, who can help me re-build riot client with functional I've made.

Can you suggest me some dev contacts who can have experience in such work, or kindly provide me some tips of how to do such things?

You can contact me in telegram as @sbekket

NoSuchElementException with a basic exemple

Using this code sample

package net.pedr0.matrixbot;

import io.github.ma1uta.matrix.client.StandaloneClient;

public class Application {
  public static void main(String[] args) {
    StandaloneClient mxClient = new StandaloneClient.Builder()
        .domain("pedr0.net")
        .build();
    
    mxClient.auth().login("bot", "password".toCharArray());
    mxClient.profile().setDisplayName("BotBot");

    String roomId = mxClient.room().joinByIdOrAlias("#test:pedr0.net", null, null).getRoomId();
    
    mxClient.event().sendMessage(roomId, "Hello, World!");
    
    mxClient.auth().logout();
  }
}

I have this exception

Exception in thread "main" java.util.NoSuchElementException
	at java.base/java.util.ServiceLoader$2.next(ServiceLoader.java:1308)
	at java.base/java.util.ServiceLoader$2.next(ServiceLoader.java:1296)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
	at io.github.ma1uta.matrix.client.AbstractHomeServerResolver.<init>(AbstractHomeServerResolver.java:83)
	at io.github.ma1uta.matrix.client.ClientHomeServerResolver.<init>(ClientHomeServerResolver.java:32)
	at io.github.ma1uta.matrix.client.MatrixClient.<init>(MatrixClient.java:95)
	at io.github.ma1uta.matrix.client.StandaloneClient.<init>(StandaloneClient.java:42)
	at io.github.ma1uta.matrix.client.StandaloneClient.<init>(StandaloneClient.java:38)
	at io.github.ma1uta.matrix.client.StandaloneClient$Builder.newInstance(StandaloneClient.java:125)
	at io.github.ma1uta.matrix.client.StandaloneClient$Builder.newInstance(StandaloneClient.java:121)
	at io.github.ma1uta.matrix.client.AbstractClientBuilder.build(AbstractClientBuilder.java:73)
	at net.pedr0.matrixbot.Application.main(Application.java:9)

Using java 11, client-impl 0.12.0 and a matrix synapse server 1.18.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.