mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Fix crash when persisting null relations
This commit is contained in:
parent
3d8f16e6c5
commit
5105d2cb96
1 changed files with 21 additions and 12 deletions
|
@ -2689,9 +2689,12 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
|
|||
if (event.contains("content") &&
|
||||
event["content"].contains("m.relates_to")) {
|
||||
auto temp = event["content"]["m.relates_to"];
|
||||
std::string relates_to = temp.contains("m.in_reply_to")
|
||||
json relates_to_j = temp.contains("m.in_reply_to") &&
|
||||
temp["m.in_reply_to"].is_object()
|
||||
? temp["m.in_reply_to"]["event_id"]
|
||||
: temp["event_id"];
|
||||
std::string relates_to =
|
||||
relates_to_j.is_string() ? relates_to_j.get<std::string>() : "";
|
||||
|
||||
if (!relates_to.empty()) {
|
||||
lmdb::dbi_del(txn,
|
||||
|
@ -2781,9 +2784,12 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
|
|||
if (event.contains("content") &&
|
||||
event["content"].contains("m.relates_to")) {
|
||||
auto temp = event["content"]["m.relates_to"];
|
||||
std::string relates_to = temp.contains("m.in_reply_to")
|
||||
json relates_to_j = temp.contains("m.in_reply_to") &&
|
||||
temp["m.in_reply_to"].is_object()
|
||||
? temp["m.in_reply_to"]["event_id"]
|
||||
: temp["event_id"];
|
||||
std::string relates_to =
|
||||
relates_to_j.is_string() ? relates_to_j.get<std::string>() : "";
|
||||
|
||||
if (!relates_to.empty())
|
||||
lmdb::dbi_put(
|
||||
|
@ -2870,9 +2876,12 @@ Cache::saveOldMessages(const std::string &room_id, const mtx::responses::Message
|
|||
|
||||
if (event.contains("content") && event["content"].contains("m.relates_to")) {
|
||||
auto temp = event["content"]["m.relates_to"];
|
||||
std::string relates_to = temp.contains("m.in_reply_to")
|
||||
json relates_to_j =
|
||||
temp.contains("m.in_reply_to") && temp["m.in_reply_to"].is_object()
|
||||
? temp["m.in_reply_to"]["event_id"]
|
||||
: temp["event_id"];
|
||||
std::string relates_to =
|
||||
relates_to_j.is_string() ? relates_to_j.get<std::string>() : "";
|
||||
|
||||
if (!relates_to.empty())
|
||||
lmdb::dbi_put(txn, relationsDb, lmdb::val(relates_to), event_id);
|
||||
|
|
Loading…
Reference in a new issue