Skip to content
Snippets Groups Projects
Commit 5832bb7c authored by Adrien Béraud's avatar Adrien Béraud
Browse files

archiver: cleanup

Change-Id: I518fd3541487e432f405ae25d707cfb2713da9fc
parent c0d06537
No related branches found
No related tags found
No related merge requests found
...@@ -55,64 +55,6 @@ using namespace std::literals; ...@@ -55,64 +55,6 @@ using namespace std::literals;
namespace jami { namespace jami {
namespace archiver { namespace archiver {
std::map<std::string, std::string>
jsonValueToAccount(Json::Value& value, const std::string& accountId)
{
auto idPath_ = fileutils::get_data_dir() / accountId;
dhtnet::fileutils::check_dir(idPath_.c_str(), 0700);
auto detailsMap = libjami::getAccountTemplate(
value[libjami::Account::ConfProperties::TYPE].asString());
for (Json::ValueIterator itr = value.begin(); itr != value.end(); itr++) {
if (itr->asString().empty())
continue;
if (itr.key().asString().compare(libjami::Account::ConfProperties::TLS::CA_LIST_FILE) == 0) {
std::string fileContent(itr->asString());
fileutils::saveFile(idPath_ / "ca.key",
{fileContent.begin(), fileContent.end()},
0600);
} else if (itr.key().asString().compare(
libjami::Account::ConfProperties::TLS::PRIVATE_KEY_FILE)
== 0) {
std::string fileContent(itr->asString());
fileutils::saveFile(idPath_ / "dht.key",
{fileContent.begin(), fileContent.end()},
0600);
} else if (itr.key().asString().compare(
libjami::Account::ConfProperties::TLS::CERTIFICATE_FILE)
== 0) {
std::string fileContent(itr->asString());
fileutils::saveFile(idPath_ / "dht.crt",
{fileContent.begin(), fileContent.end()},
0600);
} else
detailsMap[itr.key().asString()] = itr->asString();
}
return detailsMap;
}
Json::Value
accountToJsonValue(const std::map<std::string, std::string>& details)
{
Json::Value root;
for (const auto& i : details) {
if (i.first == libjami::Account::ConfProperties::Ringtone::PATH) {
// Ringtone path is not exportable
} else if (i.first == libjami::Account::ConfProperties::TLS::CA_LIST_FILE
|| i.first == libjami::Account::ConfProperties::TLS::CERTIFICATE_FILE
|| i.first == libjami::Account::ConfProperties::TLS::PRIVATE_KEY_FILE) {
// replace paths by the files content
root[i.first] = fileutils::loadTextFile(std::filesystem::path(i.second));
} else
root[i.first] = i.second;
}
return root;
}
std::vector<uint8_t> std::vector<uint8_t>
compress(const std::string& str) compress(const std::string& str)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment