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

Request and Response payloads for GET & POST publicRooms endpoints.

parent cbecb9fe
No related branches found
No related tags found
No related merge requests found
#pragma once
#include <string>
#include <vector>
#if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp>
#else
#include <nlohmann/json.hpp>
#endif
namespace mtx {
namespace responses {
struct PublicRoomsChunk
{
//! Aliases of the room. May be empty.
std::vector<std::string> aliases;
//! The canonical alias of the room, if any.
std::string canonical_alias
//! The name of the room, if any.
std::string name;
//! **Required.** The number of members joined to the room.
int num_joined_members;
//! **Required.** The ID of the room.
std::string room_id;
//! The topic of the room, if any.
std::string topic;
//! **Required.** Whether the room may be viewed by guest users without joining.
bool world_readable;
//! **Required.** Whether guest users may join the room
//! and participate in it. If they can, they will be subject
//! to ordinary power level rules like any other user.
bool guest_can_join;
//! The URL for the room's avatar, if one is set.
std::string avatar_url;
};
void
from_json(const nlohmann::json &obj, PublicRoomsChunk &res);
void
to_json(nlohmann::json &obj, const PublicRoomsChunk &res);
} // namespace responses
} // namespace mtx
\ No newline at end of file
......@@ -5,6 +5,7 @@
#include <mtx/common.hpp>
#include <mtx/events/collections.hpp>
#include <mtx/filters.hpp>
#if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp>
#else
......@@ -137,6 +138,29 @@ struct TypingNotification
void
to_json(json &obj, const TypingNotification &request);
//! Request payload for the `POST /_matrix/client/r0/publicRooms` endpoint.
struct PublicRooms
{
//! Limit the number of results returned.
int limit;
//! A pagination token from a previous request, allowing clients
//! to get the next (or previous) batch of rooms. The direction of
//! pagination is specified solely by which token is supplied,
//! rather than via an explicit flag.
std::string since;
//! Filter to apply to the results.
Filter filter;
//! Whether or not to include all known networks/protocols from
//! application services on the homeserver. Defaults to false.
bool include_all_networks = false;
//! The specific third party network/protocol to request from
//! the homeserver. Can only be used if include_all_networks is false.
std::string third_party_instance_id;
};
void
to_json(json &obj, const PostPublicRooms &request);
struct Empty
{};
......
......@@ -16,3 +16,4 @@
#include "responses/turn_server.hpp"
#include "responses/version.hpp"
#include "responses/well-known.hpp"
#include "responses/public_rooms.hpp"
#pragma once
#include <vector>
#include <string>
#if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp>
#else
#include <nlohmann/json.hpp>
#endif
#include "mtx/public_rooms_chunk.hpp"
namespace mtx {
namespace responses {
//! Response from the `GET /_matrix/client/r0/publicRooms` &
//! `POST /_matrix/client/r0/publicRooms` endpoints.
struct PublicRooms
{
//! **Required**. A paginated chunk of public rooms.
std::vector<PublicRoomsChunk> chunk;
//! A pagination token for the response. The absence
//! of this token means there are no more results to
//! fetch and the client should stop paginating.
std::string next_batch;
//! A pagination token that allows fetching previous results.
//! The absence of this token means there are no results
//! before this batch, i.e. this is the first batch.
std::string prev_batch;
//! An estimate on the total number of public rooms,
//! if the server has an estimate.
int total_room_count_estimate;
};
void
from_json(const nlohmann::json &obj, PublicRooms &publicRooms);
} // namespace responses
} // namespace mtx
\ No newline at end of file
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