matrix-org / gomatrix Goto Github PK
View Code? Open in Web Editor NEWA Golang Matrix client
License: Apache License 2.0
A Golang Matrix client
License: Apache License 2.0
Sync fails with json: cannot unmarshal number 1503606115815 into Go struct field Event.origin_server_ts of type int
. It seems int as type is too small :/
Please set the gomatrix repository to archived, or at least add a banner to the readme stating that the package is no longer maintained.
Cherry on top is to add a link to the GoLang sdk that is maintained.
github.com/matrix-org/gomatrix
Please remove it from the list of “stable” SDK on matrix.org/ecosystem/sdks/ stable is not synonymous to discontinued.
I'm still very new to Go and gomatrix, so please excuse my question if it sounds silly.
If I want to login, why do I need to instantiate NewClient with empty userID and accessToken and then proceed to SetCredentials?
Login is the first thing you must do (if you not already know the token). Why not have Login return a client with userid and access_token already set?
Something like:
func ExampleClient_Login() {
cli, _ := PasswordLogin("http://localhost:8008", "alice", "wonderland")
}
Instead of:
// Login to a local homeserver and set the user ID and access token on success.
func ExampleClient_Login() {
cli, _ := NewClient("http://localhost:8008", "", "")
resp, err := cli.Login(&ReqLogin{
Type: "m.login.password",
User: "alice",
Password: "wonderland",
})
if err != nil {
panic(err)
}
cli.SetCredentials(resp.UserID, resp.AccessToken)
}
The travis builds that are run for gomatrix are made with Go 1.10. This version of the Go toolchain is no longer supported (not since February 2019).
I just discovered HTMLMessage
, and it's not clear why it exists in this form to me. I discovered it by looking at #58, and noticed that my PR #82 seems to more naturally integrate. I don't agree with automatically shaping the HTML (what if a user sends <span>
with formatting? Now you have something like <span><span></span>
, what part's the body? Admittingly, I don't follow the regex there, though), I don't even agree simply with calling it HTML in a public type as it's merely a subset of HTML, it's just formatted text. Rather I think we should make it clear it's a subset, and link to where the differences are found.
I don't think someone receiving or sending formatted text using this library is going to commonly think to look for HTMLMessage
, which doesn't seem to be connected to anything, just an oddity. I think SendFormattedText
, linked to the spec where it was inspired (what my PR effectively is) is a lot more natural, and fits nicely along-side SendText
, we can also re-use the struct there, as that part of the spec was simply extended, we can simply extend the struct, without breaking backward compatibility (unless someone didn't name their fields while declaring, which is considered bad practice anyways).
I think we should have something more natural, and I say this because it is still just text lol. It's all grouped together in the spec, why split it up in the library? :)
In short: HTMLMessage
is very confusing as-is, and seems to break the library's flow. Let's look at the intent behind it, and implement it better.
This issue is tracking which endpoints need to be added to gomatrix. They are grouped by their appearance in the spec.
Messages takes an int
for the limit
parameter, but then converts that to a string
so it can go into the query map[string]string
map. This causes matrix to reject the request.
Some endpoints (e.g. https://matrix.org/speculator/spec/HEAD/client_server/unstable.html#get-matrix-client-r0-pushrules) require a trailing slash at the end of the path, but cli.BuildURL
seems to strip it from the built URL. Possibly tricky as it might come from the url
package.
Hi there,
what's the current state of this project? Do you have a meaningful roadmap? Versioning and tags related to the specs?
Since the godocs refer to Client Server API r0.2.0, I'm very reluctant to use this lib for a new project. Instead, I'm seriously thinking about generating an API client based on the provided swagger definitions and go-swagger.
I could be wrong, but I couldn't find any 429 handling code.
Hi,
I'm trying to build an IOU bot for matrix (https://github.com/dryvenn/matrix-iou-bot) and I was wondering:
How do I get a user's "display name" from his ID?
How do I get the list of all the users in a room?
The goal here is to map human-friendly names in a message to actual users.
Any help appreciated!
Hi,
I missed the MsgType "m.file". To help you a little, I just add it by myself. I test it with PDF files and it works fine. Hope my patch file is fine for you.
Have a nice day,
Andreas
It's a minor thing, but having a way to identify that the gomatrix client was used in the synapse logs can be helpful.
Ideally there'd be some sort of function to change the sent user agent so that other clients can modify how they are presented.
As noted in #15 olm/megolm encryption should be added to gomatrix
I have started bindings at https://github.com/NotAFile/libolm-go
This currently only supports olm
, but adding megolm
support should not be hard.
The big disadvantage of this is that there is a runtime dependency on libolm.so.2
being available on the system. However I think this is a lot better than reimplementing olm
.
I'm pretty new to go, so I'm not sure if perhaps e2e support could be enabled or disabled at compile time, or perhaps a different way could be found to integrate it with gomatrix
. I'm thinking of something like the python ssl
module which you can import separately to add TLS support to many python libraries.
Currently, there seems to be no way of fetching state with the default Syncer. You would need to essentially write your own Syncer.
Here is a zip with the files to add SharedSecretRegistration as defined by https://matrix-org.github.io/synapse/latest/admin_api/register_api.html
This API allows for the creation of users in an administrative and non-interactive way. This is generally used for bootstrapping a Synapse instance with administrator accounts.
To authenticate yourself to the server, you will need both the shared secret (registration_shared_secret in the homeserver configuration), and a one-time nonce. If the registration shared secret is not configured, this API is not enabled.
I call StopSync on the client closing. But If I do it it still first checks the Filter and tries to make a POST request. But this somehow ends into Sync err: msg=Failed to POST JSON to /_matrix/client/r0/user/filter code=400 wrapped=M_UNRECOGNIZED: Unrecognized request
. I am not sure if thats a timing issue or something but shouldn't the syncingID
be done earlier to prevent that bug?
Should endpoints be switched from r0 to v3?
Is this something gomatrix should provide? At least some
RelatesTo struct {
InReplyTo struct {
EventID string `json:"event_id"`
} `json:"m.in_reply_to"`
} `json:"m.relates_to"`
members in the structs and maybe some GetHTMLMessage-style function to generate fallback-containing reply bodies?
Any interest in adding a receipt client function to send receipts using the API endpoints
e.g.
diff --git a/client.go b/client.go
index 7725ac3..2819d8d 100644
--- a/client.go
+++ b/client.go
@@ -449,6 +449,13 @@ func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON
return
}
+func (cli *Client) Receipt(roomID, receiptType, eventID string, req *ReqReceipt) (resp *RespReceipt, err error) {
+ urlPath := cli.BuildURL("rooms", roomID, "receipt", receiptType, eventID)
+ _, err = cli.MakeRequest("POST", urlPath, req, nil)
+ return
+}
+
+
// SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey
// contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error) {
diff --git a/requests.go b/requests.go
index af99a22..f044fff 100644
--- a/requests.go
+++ b/requests.go
@@ -76,3 +76,6 @@ type ReqTyping struct {
Typing bool `json:"typing"`
Timeout int64 `json:"timeout"`
}
+
+type ReqReceipt struct {
+}
diff --git a/responses.go b/responses.go
index fe0eeb3..8539969 100644
--- a/responses.go
+++ b/responses.go
@@ -174,3 +174,6 @@ type RespTurnServer struct {
TTL int `json:"ttl"`
URIs []string `json:"uris"`
}
+
+type RespReceipt struct {
+}
Happy to cleanup and submit this as a PR if it seems reasonable
Currently this project is a glorified HTTP wrapper with some /sync
state handling and "Observer" pattern callbacks by default. This is fine for basic bots but there is much more scope for improving this. This issue maintains a list of ideas/features/improvements along with coarse timeframes for when I want to land them.
Can you create a release for this project and follow semantic versioning please? It is ok to start with v0
version to allow backward incompatible changes. So v0.1.0
could be a good start.
This will allow users to pin specific version instead of commit hash and setup auto-updating (e.g. Dependabot).
Thanks!
Add the ability to pull down a user's displayName given their userID as defined by https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname
Additionally, the ability to track the m.room.member
and m.presence
event that are sent on a displayName change as defined by https://matrix.org/docs/spec/client_server/r0.2.0.html#events-on-change-of-profile-information, would be useful.
Is there any usable code in https://github.com/tulir/gomatrix or https://github.com/tulir/mautrix-go ?
Is the scope of this project just targeting r0.2.0? I'm currently writing a bot using this library. I have no problem updating this library as I go, and submitting sensible PRs. But what's the scope?
Can we tag the master as "Matrix Spec r0.2.0" and let master move forward as "unstable"?
Or is that already the scope of this project?
Currently the CI uses Go 1.8, which isn't supported by some linters anymore, and also makes some calls to Go's tool suite which aren't supported anymore.
This looks like a trivial thing to do, just needs to be done.
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.