Skip to content
Snippets Groups Projects
Verified Commit 165c9332 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Add support for setting and resolving aliases

parent d047c366
No related branches found
No related tags found
No related merge requests found
Pipeline #2946 passed
......@@ -592,6 +592,13 @@ public:
const std::map<mtx::identifiers::User, std::map<std::string, EventContent>> &messages,
ErrCallback callback);
//! Resolve the specified roomalias to a roomid.
void resolve_room_alias(const std::string &alias, Callback<mtx::responses::RoomId> cb);
//! Add an alias to a room.
void add_room_alias(const std::string &alias, const std::string &roomid, ErrCallback cb);
//! Delete an alias from a room.
void delete_room_alias(const std::string &alias, ErrCallback cb);
//! Gets the visibility of a given room on the server's public room directory.
void get_room_visibility(const std::string &room_id,
Callback<mtx::responses::PublicRoomVisibility> cb);
......
......@@ -1103,6 +1103,31 @@ Client::send_to_device(const std::string &event_type,
put<nlohmann::json>(api_path, body, std::move(callback));
}
void
Client::resolve_room_alias(const std::string &alias, Callback<mtx::responses::RoomId> cb)
{
const auto api_path = "/client/r0/directory/room/" + mtx::client::utils::url_encode(alias);
get<mtx::responses::RoomId>(api_path,
[cb = std::move(cb)](const mtx::responses::RoomId &res,
HeaderFields,
RequestErr err) { cb(res, err); });
}
void
Client::add_room_alias(const std::string &alias, const std::string &roomid, ErrCallback cb)
{
const auto api_path = "/client/r0/directory/room/" + mtx::client::utils::url_encode(alias);
auto body = nlohmann::json::object();
body["room_id"] = roomid;
put<nlohmann::json>(api_path, body, std::move(cb));
}
void
Client::delete_room_alias(const std::string &alias, ErrCallback cb)
{
delete_("/client/r0/directory/room/" + mtx::client::utils::url_encode(alias), std::move(cb));
}
void
Client::get_room_visibility(const std::string &room_id,
Callback<mtx::responses::PublicRoomVisibility> cb)
......
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