Skip to content
Snippets Groups Projects
Commit f9d0ec07 authored by Thulinma's avatar Thulinma
Browse files

Implement device get/put endpoints

parent a94839b6
No related branches found
No related tags found
No related merge requests found
......@@ -127,6 +127,7 @@ to_json(json &obj, const AvatarUrl &request);
//! Request payload for the `PUT /_matrix/client/r0/profile/{userId}/displayname` endpoint.
struct DisplayName
{
//! The new display name for this device. If not given, the display name is unchanged.
std::string displayname;
};
......@@ -158,6 +159,15 @@ struct TypingNotification
void
to_json(json &obj, const TypingNotification &request);
//! Request payload for the `PUT /_matrix/client/r0/devices/{deviceId}` endpoint.
struct DeviceUpdate
{
std::string display_name;
};
void
to_json(json &obj, const DeviceUpdate &request);
//! Request payload for the `PUT /_matrix/client/r0/directory/list/room/{roomId}` endpoint
struct PublicRoomVisibility
{
......
......@@ -80,6 +80,7 @@ struct WellKnown;
struct PublicRoomVisibility;
struct PublicRooms;
struct QueryDevices;
struct Device;
namespace backup {
struct SessionBackup;
struct RoomKeysBackup;
......@@ -589,6 +590,14 @@ public:
//! List devices
void query_devices(Callback<mtx::responses::QueryDevices> cb);
//! Gets information on a single device, by device id.
void get_device(const std::string &device_id, Callback<mtx::responses::Device> cb);
//! Updates the display name of the given device id.
void set_device_name(const std::string &device_id,
const std::string &display_name,
ErrCallback callback);
/////! Rename device
// void rename_device(const mtx::requests::DeviceSigningUpload,
// UIAHandler uia_handler,
......
......@@ -1095,6 +1095,26 @@ Client::query_devices(Callback<mtx::responses::QueryDevices> cb)
RequestErr err) { cb(res, err); });
}
void
Client::get_device(const std::string &device_id, Callback<mtx::responses::Device> cb)
{
get<mtx::responses::Device>(
"/client/r0/devices/" + mtx::client::utils::url_encode(device_id),
[cb](const mtx::responses::Device &res, HeaderFields, RequestErr err) { cb(res, err); });
}
void
Client::set_device_name(const std::string &device_id,
const std::string &display_name,
ErrCallback callback)
{
mtx::requests::DeviceUpdate req;
req.display_name = display_name;
put<mtx::requests::DeviceUpdate>(
"/client/r0/devices/" + mtx::client::utils::url_encode(device_id), req, callback);
}
//
// Encryption related endpoints
//
......
......@@ -153,6 +153,12 @@ to_json(json &obj, const PublicRooms &request)
}
}
void
to_json(json &obj, const DeviceUpdate &request)
{
obj["display_name"] = request.display_name;
}
void
to_json(json &obj, const SignedOneTimeKey &request)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment