mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
parent
193215c067
commit
970ed56fa5
2 changed files with 9 additions and 11 deletions
|
@ -66,6 +66,7 @@ constexpr auto SYNC_STATE_DB("sync_state");
|
||||||
//! Read receipts per room/event.
|
//! Read receipts per room/event.
|
||||||
constexpr auto READ_RECEIPTS_DB("read_receipts");
|
constexpr auto READ_RECEIPTS_DB("read_receipts");
|
||||||
constexpr auto NOTIFICATIONS_DB("sent_notifications");
|
constexpr auto NOTIFICATIONS_DB("sent_notifications");
|
||||||
|
constexpr auto PRESENCE_DB("presence");
|
||||||
|
|
||||||
//! Encryption related databases.
|
//! Encryption related databases.
|
||||||
|
|
||||||
|
@ -293,6 +294,7 @@ Cache::setup()
|
||||||
invitesDb_ = lmdb::dbi::open(txn, INVITES_DB, MDB_CREATE);
|
invitesDb_ = lmdb::dbi::open(txn, INVITES_DB, MDB_CREATE);
|
||||||
readReceiptsDb_ = lmdb::dbi::open(txn, READ_RECEIPTS_DB, MDB_CREATE);
|
readReceiptsDb_ = lmdb::dbi::open(txn, READ_RECEIPTS_DB, MDB_CREATE);
|
||||||
notificationsDb_ = lmdb::dbi::open(txn, NOTIFICATIONS_DB, MDB_CREATE);
|
notificationsDb_ = lmdb::dbi::open(txn, NOTIFICATIONS_DB, MDB_CREATE);
|
||||||
|
presenceDb_ = lmdb::dbi::open(txn, PRESENCE_DB, MDB_CREATE);
|
||||||
|
|
||||||
// Device management
|
// Device management
|
||||||
devicesDb_ = lmdb::dbi::open(txn, DEVICES_DB, MDB_CREATE);
|
devicesDb_ = lmdb::dbi::open(txn, DEVICES_DB, MDB_CREATE);
|
||||||
|
@ -1701,9 +1703,7 @@ Cache::savePresence(
|
||||||
const std::vector<mtx::events::Event<mtx::events::presence::Presence>> &presenceUpdates)
|
const std::vector<mtx::events::Event<mtx::events::presence::Presence>> &presenceUpdates)
|
||||||
{
|
{
|
||||||
for (const auto &update : presenceUpdates) {
|
for (const auto &update : presenceUpdates) {
|
||||||
auto presenceDb = getPresenceDb(txn);
|
presenceDb_.put(txn, update.sender, json(update.content).dump());
|
||||||
|
|
||||||
presenceDb.put(txn, update.sender, json(update.content).dump());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3905,17 +3905,16 @@ Cache::avatarUrl(const QString &room_id, const QString &user_id)
|
||||||
mtx::events::presence::Presence
|
mtx::events::presence::Presence
|
||||||
Cache::presence(const std::string &user_id)
|
Cache::presence(const std::string &user_id)
|
||||||
{
|
{
|
||||||
|
mtx::events::presence::Presence presence_{};
|
||||||
|
presence_.presence = mtx::presence::PresenceState::offline;
|
||||||
|
|
||||||
if (user_id.empty())
|
if (user_id.empty())
|
||||||
return {};
|
return presence_;
|
||||||
|
|
||||||
std::string_view presenceVal;
|
std::string_view presenceVal;
|
||||||
|
|
||||||
auto txn = ro_txn(env_);
|
auto txn = ro_txn(env_);
|
||||||
auto db = getPresenceDb(txn);
|
auto res = presenceDb_.get(txn, user_id, presenceVal);
|
||||||
auto res = db.get(txn, user_id, presenceVal);
|
|
||||||
|
|
||||||
mtx::events::presence::Presence presence_{};
|
|
||||||
presence_.presence = mtx::presence::PresenceState::offline;
|
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
presence_ = json::parse(std::string_view(presenceVal.data(), presenceVal.size()));
|
presence_ = json::parse(std::string_view(presenceVal.data(), presenceVal.size()));
|
||||||
|
|
|
@ -638,8 +638,6 @@ private:
|
||||||
return lmdb::dbi::open(txn, std::string(room_id + "/mentions").c_str(), MDB_CREATE);
|
return lmdb::dbi::open(txn, std::string(room_id + "/mentions").c_str(), MDB_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
lmdb::dbi getPresenceDb(lmdb::txn &txn) { return lmdb::dbi::open(txn, "presence", MDB_CREATE); }
|
|
||||||
|
|
||||||
lmdb::dbi getUserKeysDb(lmdb::txn &txn) { return lmdb::dbi::open(txn, "user_key", MDB_CREATE); }
|
lmdb::dbi getUserKeysDb(lmdb::txn &txn) { return lmdb::dbi::open(txn, "user_key", MDB_CREATE); }
|
||||||
|
|
||||||
lmdb::dbi getVerificationDb(lmdb::txn &txn)
|
lmdb::dbi getVerificationDb(lmdb::txn &txn)
|
||||||
|
@ -678,6 +676,7 @@ private:
|
||||||
lmdb::dbi invitesDb_;
|
lmdb::dbi invitesDb_;
|
||||||
lmdb::dbi readReceiptsDb_;
|
lmdb::dbi readReceiptsDb_;
|
||||||
lmdb::dbi notificationsDb_;
|
lmdb::dbi notificationsDb_;
|
||||||
|
lmdb::dbi presenceDb_;
|
||||||
|
|
||||||
lmdb::dbi devicesDb_;
|
lmdb::dbi devicesDb_;
|
||||||
lmdb::dbi deviceKeysDb_;
|
lmdb::dbi deviceKeysDb_;
|
||||||
|
|
Loading…
Reference in a new issue