I’m developing a Java application that sends notifications to its users under certain circumstances.
My idea was to offer Matrix as another notification channel and use the user’s own Matrix account to send the messages. (The user has already logged in to a third-party website that also operates a Matrix server. Thanks to SSO, I can use the already stored credentials of the user to log in at the Matrix server.)
While I’m able to send Matrix messages using Cosium/matrix-communication-client, it does not seem that the user receives any push notifications (although the messages are received correctly).
There are two possible scenarios in my view:
- The Matrix server doesn’t notify the user of messages sent by themselves.
- The user’s Matrix client (Element, in my test case) ignores notifications about messages sent by the user themselves.
Is that true? Also, can I circumvent this in any way?
Please note that I don’t wish to set up a bot account, because that would require me to host a server.
Here’s the sample code to create a Matrix room and send a message:
public class Example {
public static void main(String[] args) {
MatrixResources matrix =
MatrixResources.factory()
.builder()
.https()
.hostname("matrix.example.org")
.defaultPort()
.usernamePassword("jdoe", "secret")
.build();
RoomResource room = matrix
.rooms()
.create(
CreateRoomInput.builder()
.name("Science")
.roomAliasName("science")
.topic("Anything about science")
.build());
room.sendMessage(Message.builder().body("Hello !").formattedBody("<b>Hello !</b>").build());
}
}