|
|
@ -102,9 +102,9 @@ public: |
|
|
|
std::size_t len = 30); |
|
|
|
std::size_t len = 30); |
|
|
|
|
|
|
|
|
|
|
|
void saveState(const mtx::responses::Sync &res); |
|
|
|
void saveState(const mtx::responses::Sync &res); |
|
|
|
bool isInitialized() const; |
|
|
|
bool isInitialized(); |
|
|
|
|
|
|
|
|
|
|
|
std::string nextBatchToken() const; |
|
|
|
std::string nextBatchToken(); |
|
|
|
|
|
|
|
|
|
|
|
void deleteData(); |
|
|
|
void deleteData(); |
|
|
|
|
|
|
|
|
|
|
@ -149,8 +149,8 @@ public: |
|
|
|
using UserReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>; |
|
|
|
using UserReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>; |
|
|
|
UserReceipts readReceipts(const QString &event_id, const QString &room_id); |
|
|
|
UserReceipts readReceipts(const QString &event_id, const QString &room_id); |
|
|
|
|
|
|
|
|
|
|
|
QByteArray image(const QString &url) const; |
|
|
|
QByteArray image(const QString &url); |
|
|
|
QByteArray image(lmdb::txn &txn, const std::string &url) const; |
|
|
|
QByteArray image(lmdb::txn &txn, const std::string &url); |
|
|
|
void saveImage(const std::string &url, const std::string &data); |
|
|
|
void saveImage(const std::string &url, const std::string &data); |
|
|
|
void saveImage(const QString &url, const QByteArray &data); |
|
|
|
void saveImage(const QString &url, const QByteArray &data); |
|
|
|
|
|
|
|
|
|
|
@ -330,8 +330,8 @@ private: |
|
|
|
// void removeLeftRoom(lmdb::txn &txn, const std::string &room_id);
|
|
|
|
// void removeLeftRoom(lmdb::txn &txn, const std::string &room_id);
|
|
|
|
template<class T> |
|
|
|
template<class T> |
|
|
|
void saveStateEvents(lmdb::txn &txn, |
|
|
|
void saveStateEvents(lmdb::txn &txn, |
|
|
|
const lmdb::dbi &statesdb, |
|
|
|
lmdb::dbi &statesdb, |
|
|
|
const lmdb::dbi &membersdb, |
|
|
|
lmdb::dbi &membersdb, |
|
|
|
const std::string &room_id, |
|
|
|
const std::string &room_id, |
|
|
|
const std::vector<T> &events) |
|
|
|
const std::vector<T> &events) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -341,8 +341,8 @@ private: |
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
template<class T> |
|
|
|
void saveStateEvent(lmdb::txn &txn, |
|
|
|
void saveStateEvent(lmdb::txn &txn, |
|
|
|
const lmdb::dbi &statesdb, |
|
|
|
lmdb::dbi &statesdb, |
|
|
|
const lmdb::dbi &membersdb, |
|
|
|
lmdb::dbi &membersdb, |
|
|
|
const std::string &room_id, |
|
|
|
const std::string &room_id, |
|
|
|
const T &event) |
|
|
|
const T &event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -363,17 +363,11 @@ private: |
|
|
|
// Lightweight representation of a member.
|
|
|
|
// Lightweight representation of a member.
|
|
|
|
MemberInfo tmp{display_name, e->content.avatar_url}; |
|
|
|
MemberInfo tmp{display_name, e->content.avatar_url}; |
|
|
|
|
|
|
|
|
|
|
|
lmdb::dbi_put(txn, |
|
|
|
membersdb.put(txn, e->state_key, json(tmp).dump()); |
|
|
|
membersdb, |
|
|
|
|
|
|
|
lmdb::val(e->state_key), |
|
|
|
|
|
|
|
lmdb::val(json(tmp).dump())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
default: { |
|
|
|
default: { |
|
|
|
lmdb::dbi_del( |
|
|
|
membersdb.del(txn, e->state_key, ""); |
|
|
|
txn, membersdb, lmdb::val(e->state_key), lmdb::val("")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -387,11 +381,8 @@ private: |
|
|
|
if (!isStateEvent(event)) |
|
|
|
if (!isStateEvent(event)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
std::visit( |
|
|
|
std::visit([&txn, &statesdb]( |
|
|
|
[&txn, &statesdb](auto e) { |
|
|
|
auto e) { statesdb.put(txn, to_string(e.type), json(e).dump()); }, |
|
|
|
lmdb::dbi_put( |
|
|
|
|
|
|
|
txn, statesdb, lmdb::val(to_string(e.type)), lmdb::val(json(e).dump())); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
event); |
|
|
|
event); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|