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

Store errors as strings to speed up compilation

parent f878e294
Branches reportContent
No related tags found
No related merge requests found
Pipeline #5210 passed
......@@ -35,7 +35,7 @@ struct QueryKeys
//! If any remote homeservers could not be reached, they are
//! recorded here. The names of the properties are the names
//! of the unreachable servers.
std::map<std::string, nlohmann::json> failures;
std::map<std::string, std::string> failures;
//! Information on the queried devices.
//! A map from user ID, to a map from device ID to device information.
//! For each device, the information returned will be the same
......@@ -67,7 +67,7 @@ struct ClaimKeys
//! If any remote homeservers could not be reached, they are
//! recorded here. The names of the properties are the names
//! of the unreachable servers.
std::map<std::string, nlohmann::json> failures;
std::map<std::string, std::string> failures;
//! One-time keys for the queried devices. A map from user ID,
//! to a map from <algorithm>:<key_id> to the key object.
std::map<std::string, std::map<std::string, nlohmann::json>> one_time_keys;
......
......@@ -15,8 +15,11 @@ from_json(const nlohmann::json &obj, UploadKeys &response)
void
from_json(const nlohmann::json &obj, QueryKeys &response)
{
if (obj.contains("failures"))
response.failures = obj.at("failures").get<std::map<std::string, nlohmann::json>>();
if (obj.contains("failures")) {
for (const auto &[key, value] :
obj.at("failures").get<std::map<std::string, nlohmann::json>>())
response.failures[key] = value.dump();
}
if (obj.contains("device_keys"))
response.device_keys = obj.at("device_keys").get<std::map<std::string, DeviceToKeysMap>>();
if (obj.contains("master_keys"))
......@@ -33,7 +36,9 @@ from_json(const nlohmann::json &obj, QueryKeys &response)
void
to_json(nlohmann::json &obj, const QueryKeys &response)
{
obj["failures"] = response.failures;
for (const auto &[key, value] : response.failures)
obj["failures"][key] = nlohmann::json::parse(value);
obj["device_keys"] = response.device_keys;
obj["master_keys"] = response.master_keys;
obj["user_signing_keys"] = response.user_signing_keys;
......@@ -50,8 +55,11 @@ from_json(const nlohmann::json &obj, KeySignaturesUpload &response)
void
from_json(const nlohmann::json &obj, ClaimKeys &response)
{
if (obj.contains("failures"))
response.failures = obj.at("failures").get<std::map<std::string, nlohmann::json>>();
if (obj.contains("failures")) {
for (const auto &[key, value] :
obj.at("failures").get<std::map<std::string, nlohmann::json>>())
response.failures[key] = value.dump();
}
if (obj.contains("one_time_keys"))
response.one_time_keys =
obj.at("one_time_keys")
......
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