Skip to content
Snippets Groups Projects
Unverified Commit 2aec3756 authored by NepNep21's avatar NepNep21
Browse files

Resolve reviews

parent cfc63a1c
No related branches found
No related tags found
No related merge requests found
Pipeline #4902 failed
......@@ -13,18 +13,16 @@ namespace mtx {
namespace events {
namespace account_data {
namespace data {
//! An entry in `m.ignored_user_list`. Currently only the key (mxid) is supported, not arbitrary
//! values.
struct IgnoredUser
{
std::string id;
};
} // namespace data
struct IgnoredUsers
{
std::vector<data::IgnoredUser> users;
std::vector<IgnoredUser> users;
//! Deserialization method needed by @p nlohmann::json.
friend void from_json(const nlohmann::json &obj, IgnoredUsers &content);
......
......@@ -10,9 +10,11 @@ namespace account_data {
void
from_json(const nlohmann::json &obj, IgnoredUsers &content)
{
const auto map = obj.at("ignored_users").get<std::unordered_map<std::string, nlohmann::json>>();
for (const auto &[key, value] : map) {
data::IgnoredUser user;
if (!obj.contains("ignored_users"))
return;
for (const auto &[key, value] : obj.at("ignored_users").items()) {
IgnoredUser user;
user.id = key;
content.users.push_back(user);
}
......@@ -22,7 +24,7 @@ void
to_json(nlohmann::json &obj, const IgnoredUsers &content)
{
std::unordered_map<std::string, nlohmann::json> map;
for (const data::IgnoredUser &user : content.users) {
for (const IgnoredUser &user : content.users) {
map[user.id] = {};
}
obj["ignored_users"] = map;
......
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