diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-29 10:51:09 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-29 10:51:09 +0100 |
commit | 2649e41c85283c680b9e1aa3294868b985aecc22 (patch) | |
tree | 67a37cd6044f217e9be5fe217efaf86d040f06bc /mxlib | |
parent | 38a3f1bdb18159cc4808fa86280da55f0599dcc8 (diff) | |
download | easybridge-2649e41c85283c680b9e1aa3294868b985aecc22.tar.gz easybridge-2649e41c85283c680b9e1aa3294868b985aecc22.zip |
Allow _ezbr_ to be put in suffix of usernames/room aliases instead of prefix
Diffstat (limited to 'mxlib')
-rw-r--r-- | mxlib/client.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mxlib/client.go b/mxlib/client.go index 71bba3f..c111360 100644 --- a/mxlib/client.go +++ b/mxlib/client.go @@ -78,6 +78,17 @@ func (mx *Client) PostApiCall(endpoint string, data interface{}, response interf return mx.DoAndParse(req, response) } +func (mx *Client) DeleteApiCall(endpoint string, response interface{}) error { + log.Debugf("Matrix DELETE request: %s\n", endpoint) + + req, err := http.NewRequest("DELETE", mx.Server+endpoint, nil) + if err != nil { + return err + } + + return mx.DoAndParse(req, response) +} + func (mx *Client) DoAndParse(req *http.Request, response interface{}) error { if mx.Token != "" { req.Header.Add("Authorization", "Bearer "+mx.Token) @@ -181,6 +192,15 @@ func (mx *Client) DirectoryRoom(alias string) (string, error) { return rep.RoomId, nil } +func (mx *Client) DirectoryDeleteRoom(alias string) error { + var rep struct{} + err := mx.DeleteApiCall("/_matrix/client/r0/directory/room/"+url.QueryEscape(alias), &rep) + if err != nil { + return err + } + return nil +} + func (mx *Client) CreateRoom(name string, alias string, invite []string) (string, error) { rq := CreateRoomRequest{ Preset: "private_chat", |