mirror of https://github.com/matrix-org/gomatrix
Merge 2bddc06315
into a7fc80c806
This commit is contained in:
commit
ecf6ecb2ca
27
client.go
27
client.go
|
@ -529,7 +529,7 @@ func (cli *Client) ForgetRoom(roomID string) (resp *RespForgetRoom, err error) {
|
||||||
// InviteUser invites a user to a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite
|
// InviteUser invites a user to a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite
|
||||||
func (cli *Client) InviteUser(roomID string, req *ReqInviteUser) (resp *RespInviteUser, err error) {
|
func (cli *Client) InviteUser(roomID string, req *ReqInviteUser) (resp *RespInviteUser, err error) {
|
||||||
u := cli.BuildURL("rooms", roomID, "invite")
|
u := cli.BuildURL("rooms", roomID, "invite")
|
||||||
_, err = cli.MakeRequest("POST", u, struct{}{}, &resp)
|
_, err = cli.MakeRequest("POST", u, req, &resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,3 +701,28 @@ func NewClient(homeserverURL, userID, accessToken string) (*Client, error) {
|
||||||
|
|
||||||
return &cli, nil
|
return &cli, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewClientWithHTTPClient creates a new Matrix Client ready for syncing, using
|
||||||
|
// the supplied HTTP client.
|
||||||
|
func NewClientWithHTTPClient(homeserverURL, userID, accessToken string, client *http.Client) (*Client, error) {
|
||||||
|
hsURL, err := url.Parse(homeserverURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// By default, use an in-memory store which will never save filter ids / next batch tokens to disk.
|
||||||
|
// The client will work with this storer: it just won't remember across restarts.
|
||||||
|
// In practice, a database backend should be used.
|
||||||
|
store := NewInMemoryStore()
|
||||||
|
cli := Client{
|
||||||
|
AccessToken: accessToken,
|
||||||
|
HomeserverURL: hsURL,
|
||||||
|
UserID: userID,
|
||||||
|
Prefix: "/_matrix/client/r0",
|
||||||
|
Syncer: NewDefaultSyncer(userID, store),
|
||||||
|
Store: store,
|
||||||
|
}
|
||||||
|
// By default, use the default HTTP client.
|
||||||
|
cli.Client = client
|
||||||
|
|
||||||
|
return &cli, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue