mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Add client wrapper functions for Device Management endpoints
https://matrix.org/docs/spec/client_server/r0.6.1#id73 Signed-off-by: David Florness <david@florness.com>
This commit is contained in:
parent
ff59b6bd65
commit
93eac986d6
3 changed files with 59 additions and 0 deletions
30
client.go
30
client.go
|
|
@ -1097,6 +1097,36 @@ func (cli *Client) SendToDevice(eventType event.Type, req *ReqSendToDevice) (res
|
|||
return
|
||||
}
|
||||
|
||||
func (cli *Client) GetDevicesInfo() (resp *RespDevicesInfo, err error) {
|
||||
urlPath := cli.BuildURL("devices")
|
||||
_, err = cli.MakeRequest("GET", urlPath, nil, &resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (cli *Client) GetDeviceInfo(deviceID id.DeviceID) (resp *RespDeviceInfo, err error) {
|
||||
urlPath := cli.BuildURL("devices", deviceID)
|
||||
_, err = cli.MakeRequest("GET", urlPath, nil, &resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (cli *Client) SetDeviceInfo(deviceID id.DeviceID, req *ReqDeviceInfo) error {
|
||||
urlPath := cli.BuildURL("devices", deviceID)
|
||||
_, err := cli.MakeRequest("PUT", urlPath, req, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteDevice(deviceID id.DeviceID, req *ReqDeleteDevice) error {
|
||||
urlPath := cli.BuildURL("devices", deviceID)
|
||||
_, err := cli.MakeRequest("DELETE", urlPath, req, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteDevices(req *ReqDeleteDevices) error {
|
||||
urlPath := cli.BuildURL("delete_devices")
|
||||
_, err := cli.MakeRequest("DELETE", urlPath, req, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
type UIACallback = func(*RespUserInteractive) interface{}
|
||||
|
||||
// UploadCrossSigningKeys uploads the given cross-signing keys to the server.
|
||||
|
|
|
|||
16
requests.go
16
requests.go
|
|
@ -271,6 +271,22 @@ type ReqSendToDevice struct {
|
|||
Messages map[id.UserID]map[id.DeviceID]*event.Content `json:"messages"`
|
||||
}
|
||||
|
||||
// ReqDeviceInfo is the JSON request for https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-devices-deviceid
|
||||
type ReqDeviceInfo struct {
|
||||
DisplayName string `json:"display_name,omitempty"`
|
||||
}
|
||||
|
||||
// ReqDeleteDevice is the JSON request for https://matrix.org/docs/spec/client_server/r0.6.1#delete-matrix-client-r0-devices-deviceid
|
||||
type ReqDeleteDevice struct {
|
||||
Auth interface{} `json:"auth,omitempty"`
|
||||
}
|
||||
|
||||
// ReqDeleteDevices is the JSON request for https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-delete-devices
|
||||
type ReqDeleteDevices struct {
|
||||
Devices []id.DeviceID `json:"devices"`
|
||||
Auth interface{} `json:"auth,omitempty"`
|
||||
}
|
||||
|
||||
type ReqPutPushRule struct {
|
||||
Before string `json:"-"`
|
||||
After string `json:"-"`
|
||||
|
|
|
|||
13
responses.go
13
responses.go
|
|
@ -268,3 +268,16 @@ type RespKeyChanges struct {
|
|||
}
|
||||
|
||||
type RespSendToDevice struct{}
|
||||
|
||||
// RespDevicesInfo is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices
|
||||
type RespDevicesInfo struct {
|
||||
Devices []RespDeviceInfo `json:"devices"`
|
||||
}
|
||||
|
||||
// RespDeviceInfo is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices-deviceid
|
||||
type RespDeviceInfo struct {
|
||||
DeviceID id.DeviceID `json:"device_id"`
|
||||
DisplayName string `json:"display_name"`
|
||||
LastSeenIP string `json:"last_seen_ip"`
|
||||
LastSeenTS int64 `json:"last_seen_ts"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue