Giter Site home page Giter Site logo

gomatrix's People

Contributors

26000 avatar 42wim avatar anoadragon453 avatar babolivier avatar btittelbach avatar cromfr avatar dzananganic avatar f4814 avatar jcgruenhage avatar kegsay avatar mtrnord avatar negativemjark avatar neilalexander avatar northernsage avatar ptman avatar rxl881 avatar sumukha-pk avatar t3chguy avatar thediscordian avatar turt2live 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  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  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  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

gomatrix's Issues

Unable to Sync

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 request this repo

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.

https://fosstodon.org/@lil5/111940191501771658

Would it not be easier if Login would return a valid client?

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)
}

Retire `HTMLMessage`

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.

Endpoint checklist

This issue is tracking which endpoints need to be added to gomatrix. They are grouped by their appearance in the spec.

API Standards

  • GET /_matrix/client/versions

Login

  • POST /_matrix/client/r0/login
  • POST /_matrix/client/r0/logout

Account registration and management

  • POST /_matrix/client/r0/register
  • POST /_matrix/client/r0/register/email/requestToken
  • POST /_matrix/client/r0/account/password/email/requestToken
  • POST /_matrix/client/r0/account/deactivate
  • POST /_matrix/client/r0/account/password

Adding Account Administrative Contact Information

  • GET /_matrix/client/r0/account/3pid
  • POST /_matrix/client/r0/account/3pid
  • POST /_matrix/client/r0/account/3pid/email/requestToken

Filtering

  • GET /_matrix/client/r0/user/{userId}/filter/{filterId}
  • POST /_matrix/client/r0/user/{userId}/filter

Syncing

  • GET /_matrix/client/r0/sync

Getting events for a room

  • GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}
  • GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}
  • GET /_matrix/client/r0/rooms/{roomId}/state
  • GET /_matrix/client/r0/rooms/{roomId}/members
  • GET /_matrix/client/r0/rooms/{roomId}/messages
  • GET /_matrix/client/r0/rooms/{roomId}/initialSync

Sending events to a room

  • PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}
  • PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}
  • PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}

Redactions

  • PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}

Room creation

  • POST /_matrix/client/r0/createRoom

Room Aliases

  • PUT /_matrix/client/r0/directory/room/{roomAlias}
  • DELETE /_matrix/client/r0/directory/room/{roomAlias}
  • GET /_matrix/client/r0/directory/room/{roomAlias}

Room Membership

  • POST /_matrix/client/r0/rooms/{roomId}/invite
  • POST /_matrix/client/r0/join/{roomIdOrAlias}
  • POST /_matrix/client/r0/rooms/{roomId}/join
  • POST /_matrix/client/r0/rooms/{roomId}/forget
  • POST /_matrix/client/r0/rooms/{roomId}/leave
  • POST /_matrix/client/r0/rooms/{roomId}/kick
  • POST /_matrix/client/r0/rooms/{roomId}/unban
  • POST /_matrix/client/r0/rooms/{roomId}/ban

Listing Rooms

  • GET /_matrix/client/r0/publicRooms
  • POST /_matrix/client/r0/publicRooms

Profiles

  • PUT /_matrix/client/r0/profile/{userId}/displayname
  • GET /_matrix/client/r0/profile/{userId}/displayname
  • PUT /_matrix/client/r0/profile/{userId}/avatar_url
  • GET /_matrix/client/r0/profile/{userId}/avatar_url
  • GET /_matrix/client/r0/profile/{userId}

VoIP

  • GET /_matrix/client/r0/voip/turnServer

Typing

  • PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}

Presence

  • PUT /_matrix/client/r0/presence/{userId}/status
  • GET /_matrix/client/r0/presence/{userId}/status
  • POST /_matrix/client/r0/presence/list/{userId}
  • GET /_matrix/client/r0/presence/list/{userId}

Content Repository

  • GET /_matrix/media/r0/download/{serverName}/{mediaId}
  • POST /_matrix/media/r0/upload
  • GET /_matrix/media/r0/thumbnail/{serverName}/{mediaId}

Send-to-device Messaging

  • PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}

Device Management

  • GET /_matrix/client/r0/devices
  • GET /_matrix/client/r0/devices/{deviceId}
  • PUT /_matrix/client/r0/devices/{deviceId}
  • DELETE /_matrix/client/r0/devices/{deviceId}

Push Notifications

  • GET /_matrix/client/r0/pushers
  • POST /_matrix/client/r0/pushers/set
  • GET /_matrix/client/r0/notifications
  • GET /_matrix/client/r0/pushrules/
  • GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}
  • DELETE /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}
  • PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}
  • GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled
  • PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled
  • GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions
  • PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions

Search

  • POST /_matrix/client/r0/search

Room Tagging

  • PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
  • DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
  • GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags

Client Config

  • PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}
  • PUT /_matrix/client/r0/user/{userId}/account_data/{type}

Server Administration

  • GET /_matrix/client/r0/admin/whois/{userId}

Event Context

  • GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}

AS Membership List APIs

  • GET /_matrix/client/r0/rooms/{roomId}/joined_members
  • GET /_matrix/client/r0/joined_rooms

Messages() does not work with limit argument

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.

Project State / Roadmap

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.

Send an identifiable User Agent

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.

Add olm encryption

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.

Add Option to Fetch Full States

Currently, there seems to be no way of fetching state with the default Syncer. You would need to essentially write your own Syncer.

Add /_synapse/admin/v1/register

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.

gomatrixplus.zip

StopSync breaks gomatrix

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?

r0 -> v3

Should endpoints be switched from r0 to v3?

Reply support

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?

Receipt client function

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

Roadmap

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.

Short-term

  • Intent-driven APIs: (inspired by the bridge component of the same name)
    • Will auto-join rooms if "not in room" errors are encountered.
    • Will try to assert that the client has enough power level to perform the intended action.
    • Should we do this by default or add a layer on top? If by default, can we turn it off? Per-request or globally?
  • Scheduler API (inspired by the JS SDK class of the same name)
    • For both message sending and membership operations. JS SDK only does message sending.
  • Olm encryption.

Medium-term

  • Megolm encryption.
  • Implement all known APIs (#9).
  • Room timeline management (what JS SDK does)

Semver release

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!

Matrix r0.2.0 -> Latest

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?

Fix CI

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.

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.