Share historical keys

We share all keys with our devices and ones created by us to other
users.
This commit is contained in:
Nicolas Werner 2021-07-17 02:14:44 +02:00
parent 9fadd14871
commit 3f0aa13cb6
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 56 additions and 23 deletions

View file

@ -582,6 +582,25 @@ Cache::getOutboundMegolmSession(const std::string &room_id)
}
}
std::optional<GroupSessionData>
Cache::getMegolmSessionData(const MegolmSessionIndex &index)
{
try {
using namespace mtx::crypto;
auto txn = ro_txn(env_);
std::string_view value;
if (megolmSessionDataDb_.get(txn, json(index).dump(), value)) {
return nlohmann::json::parse(value).get<GroupSessionData>();
}
return std::nullopt;
} catch (std::exception &e) {
nhlog::db()->error("Failed to retrieve Megolm Session Data: {}", e.what());
return std::nullopt;
}
}
//
// OLM sessions.
//
@ -4622,6 +4641,11 @@ inboundMegolmSessionExists(const MegolmSessionIndex &index)
{
return instance_->inboundMegolmSessionExists(index);
}
std::optional<GroupSessionData>
getMegolmSessionData(const MegolmSessionIndex &index)
{
return instance_->getMegolmSessionData(index);
}
//
// Olm Sessions