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

Fix space suggestion

parent b706492d
No related branches found
No related tags found
No related merge requests found
Pipeline #3485 failed
......@@ -66,6 +66,11 @@ struct Child
/// of more than 50 characters, are forbidden and the field should be ignored if received.
std::optional<std::string> order;
//! Optional (default false) flag to denote whether the child is “suggested” or of interest to
//! members of the space. This is primarily intended as a rendering hint for clients to display
//! the room differently, such as eagerly rendering them in the room list.
bool suggested = false;
friend void from_json(const nlohmann::json &obj, Child &child);
friend void to_json(nlohmann::json &obj, const Child &child);
};
......
......@@ -21,6 +21,8 @@ from_json(const nlohmann::json &obj, Parent &parent)
void
to_json(nlohmann::json &obj, const Parent &parent)
{
obj = nlohmann::json::object();
// event without via is invalid.
if (!parent.via.has_value() || parent.via.value().empty())
return;
......@@ -53,11 +55,15 @@ from_json(const nlohmann::json &obj, Child &child)
if (obj.contains("order") && obj.at("order").is_string() &&
is_valid_order_str(obj.at("order").get<std::string>()))
child.order = obj.at("order").get<std::string>();
child.suggested = obj.value("suggested", false);
}
void
to_json(nlohmann::json &obj, const Child &child)
{
obj = nlohmann::json::object();
// event without via is invalid.
if (!child.via.has_value() || child.via.value().empty())
return;
......@@ -66,6 +72,9 @@ to_json(nlohmann::json &obj, const Child &child)
if (child.order && is_valid_order_str(child.order.value()))
obj["order"] = child.order.value();
if (child.suggested)
obj["suggested"] = true;
}
}
} // namespace state
......
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