From 2649e41c85283c680b9e1aa3294868b985aecc22 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 29 Feb 2020 10:51:09 +0100 Subject: Allow _ezbr_ to be put in suffix of usernames/room aliases instead of prefix --- mxlib/client.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mxlib') 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", -- cgit v1.2.3