diff options
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", |