Changeset View
Changeset View
Standalone View
Standalone View
src/client/actions/encryption.cpp
| Show All 9 Lines | |||||
| #include <zug/transducer/cat.hpp> | #include <zug/transducer/cat.hpp> | ||||
| #include "encryption.hpp" | #include "encryption.hpp" | ||||
| #include <immer-utils.hpp> | #include <immer-utils.hpp> | ||||
| #include <debug.hpp> | #include <debug.hpp> | ||||
| #include "cursorutil.hpp" | #include "cursorutil.hpp" | ||||
| #include "status-utils.hpp" | #include "status-utils.hpp" | ||||
| #include "key-export.hpp" | |||||
| namespace Kazv | namespace Kazv | ||||
| { | { | ||||
| using namespace CryptoConstants; | using namespace CryptoConstants; | ||||
| static json convertSignature(const ClientModel &m, std::string signature) | static json convertSignature(const ClientModel &m, std::string signature) | ||||
| { | { | ||||
| auto j = json::object(); | auto j = json::object(); | ||||
| ▲ Show 20 Lines • Show All 657 Lines • ▼ Show 20 Lines | ClientResult updateClient(ClientModel m, PrepareForSharingRoomKeyAction a) | ||||
| } | } | ||||
| } | } | ||||
| ); | ); | ||||
| return { std::move(m), [txnId](auto &&) { | return { std::move(m), [txnId](auto &&) { | ||||
| return EffectStatus(/* succ = */ true, json::object({{"txnId", txnId}})); | return EffectStatus(/* succ = */ true, json::object({{"txnId", txnId}})); | ||||
| } }; | } }; | ||||
| } | } | ||||
| ClientResult updateClient(ClientModel m, ImportFromKeyBackupFileAction a) | |||||
| { | |||||
| auto maybeExportFile = decryptKeyExport(std::move(a.fileContent), std::move(a.password)); | |||||
| if (!maybeExportFile) { | |||||
| return {std::move(m), Kazv::detail::ReturnEffectStatusT{{ | |||||
| /* succ = */ false, | |||||
| json{ | |||||
| {"errorCode", maybeExportFile.reason()}, | |||||
| {"error", maybeExportFile.reason()}, | |||||
| }, | |||||
| }}}; | |||||
| } | |||||
| std::size_t imported = 0; | |||||
| m.withCrypto([&maybeExportFile, &imported](Crypto &c) { | |||||
| imported = c.importInboundGroupSessions(std::move(maybeExportFile).value()); | |||||
| }); | |||||
| return {std::move(m), Kazv::detail::ReturnEffectStatusT{{ | |||||
| /* succ = */ true, | |||||
| json{ | |||||
| {"imported", imported}, | |||||
| }, | |||||
| }}}; | |||||
| }; | |||||
| } | } | ||||