Skip to content
Snippets Groups Projects
Commit cfba58cc authored by kamathmanu's avatar kamathmanu
Browse files

Client API for viewing public room directory

parent 83469b56
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ struct Login;
struct QueryKeys;
struct ClaimKeys;
struct UploadKeys;
struct PublicRooms;
}
namespace responses {
struct AvatarUrl;
......@@ -69,6 +70,7 @@ struct TurnServer;
struct UploadKeys;
struct Versions;
struct WellKnown;
struct PublicRooms;
namespace backup {
struct SessionBackup;
struct RoomKeysBackup;
......@@ -446,6 +448,12 @@ public:
const std::map<mtx::identifiers::User, std::map<std::string, EventContent>> &messages,
ErrCallback callback);
//! POST a new room listing to the public rooms directory.
void post_public_rooms(const std::string &server, const nhlomann::json &j,
Callback<mtx::responses::PublicRooms> cb);
//! GET the public rooms directory listing.
void get_public_rooms(int limit, const std::string &since, const std::string &server,
Callback<mtx::responses::PublicRooms> cb);
//
// Group related endpoints.
//
......
......@@ -962,6 +962,25 @@ Client::send_to_device(const std::string &event_type,
put<nlohmann::json>(api_path, body, callback);
}
void
Client::post_public_rooms(const std::string &server, const nhlomann::json &j,
Callback<mtx::responses::PublicRooms> cb)
{
const auto api_path = "/client/r0/publicRooms" + " " + server;
post<mtx::requests::PublicRooms, mtx::responses::PublicRooms>(
api_path, j, cb);
}
void
Client::get_public_rooms(int limit, const std::string &since, const std::string &server,
Callback<mtx::responses::PublicRooms> cb)
{
const auto api_path =
"/client/r0/publicRooms" + " " + std::to_string(limit) + " " + since + " " + server;
get<mtx::requests::PublicRooms, mtx::responses::PublicRooms>(api_path, cb);
}
//
// Group related endpoints.
//
......
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