Mark encrypted rooms when processing room state
This commit is contained in:
parent
604cdcec8a
commit
7ecabcd614
|
@ -29,6 +29,8 @@
|
|||
#include <mtxclient/crypto/client.hpp>
|
||||
#include <mutex>
|
||||
|
||||
#include "Logging.hpp"
|
||||
|
||||
using mtx::events::state::JoinRule;
|
||||
|
||||
struct RoomMember
|
||||
|
@ -345,7 +347,7 @@ public:
|
|||
bool isNotificationSent(const std::string &event_id);
|
||||
|
||||
//! Mark a room that uses e2e encryption.
|
||||
void setEncryptedRoom(const std::string &room_id);
|
||||
void setEncryptedRoom(lmdb::txn &txn, const std::string &room_id);
|
||||
bool isRoomEncrypted(const std::string &room_id);
|
||||
|
||||
//! Save the public keys for a device.
|
||||
|
@ -467,6 +469,9 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (mpark::holds_alternative<StateEvent<Encryption>>(event)) {
|
||||
setEncryptedRoom(txn, room_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,14 +183,12 @@ Cache::setup()
|
|||
}
|
||||
|
||||
void
|
||||
Cache::setEncryptedRoom(const std::string &room_id)
|
||||
Cache::setEncryptedRoom(lmdb::txn &txn, const std::string &room_id)
|
||||
{
|
||||
nhlog::db()->info("mark room {} as encrypted", room_id);
|
||||
|
||||
auto txn = lmdb::txn::begin(env_);
|
||||
auto db = lmdb::dbi::open(txn, ENCRYPTED_ROOMS_DB, MDB_CREATE);
|
||||
lmdb::dbi_put(txn, db, lmdb::val(room_id), lmdb::val("0"));
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -284,13 +284,6 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
|
|||
auto decrypted =
|
||||
parseEncryptedEvent(mpark::get<EncryptedEvent<msg::Encrypted>>(event));
|
||||
return parseMessageEvent(decrypted, direction);
|
||||
} else if (mpark::holds_alternative<StateEvent<state::Encryption>>(event)) {
|
||||
try {
|
||||
cache::client()->setEncryptedRoom(room_id_.toStdString());
|
||||
} catch (const lmdb::error &e) {
|
||||
nhlog::db()->critical("failed to save room {} as encrypted",
|
||||
room_id_.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in New Issue