Fix keys upload

This commit is contained in:
timoreo 2023-12-12 19:38:48 +01:00
parent 95deba1139
commit 6d83e1d4d3
Signed by: timoreo
GPG key ID: 121A72C3512BA288

View file

@ -967,23 +967,20 @@ json_t* Client::get_device_keys() {
size_t acclen = acc.get_identity_json_length();
std::unique_ptr<uint8_t[]> acckeys = std::make_unique<uint8_t[]>(acclen);
size_t bytes = acc.get_identity_json(acckeys.get(), acclen);
std::cout << "Parsing bytes" << std::endl;
json_error_t error;
sleep(5);
std::cout << "Heading into it..." << std::endl;
json_t* keys = json_loadb(reinterpret_cast<const char*>(acckeys.get()), bytes, 0, &error);
if (keys == nullptr) {
printf("error: on line %d at char %d: %s\n", error.line, error.column, error.text);
sleep(10);
}
std::cout << "Reloaded data" << std::endl;
std::cout << "Adding bits" << std::endl;
// Merge keys
json_object_set(device_keys, ("ed25519:" + getDeviceId()).c_str(), json_object_get(keys, "ed25519"));
json_object_set(device_keys, ("curve25519:" + getDeviceId()).c_str(), json_object_get(keys, "curve25519"));
json_t* keysobj = json_object();
json_object_set(keysobj, ("ed25519:" + getDeviceId()).c_str(), json_object_get(keys, "ed25519"));
json_object_set(keysobj, ("curve25519:" + getDeviceId()).c_str(), json_object_get(keys, "curve25519"));
json_decref(keys);
std::cout << "Finalizing" << std::endl;
json_object_set_new(device_keys, "keys", keysobj);
return device_keys;
}
json_t* Client::get_fallback_keys() {