Fix bug that prevented storing member events in the same database as the rest

emoji-font-selection
Nicolas Werner 2 years ago
parent d8df6de6ab
commit 9399e68fda
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 28
      src/Cache_p.h

@ -412,14 +412,18 @@ private:
break;
}
}
// BUG(Nico): Ideally we would fall through and store this in the database, but it seems
// to currently corrupt the db sometimes, so... let's find that bug first!
} else if (auto encr = std::get_if<StateEvent<Encryption>>(&event)) {
if (!encr->state_key.empty())
return;
} else if (std::holds_alternative<StateEvent<Encryption>>(event)) {
setEncryptedRoom(txn, room_id);
std::string_view temp;
// ensure we don't replace the event in the db
if (statesdb.get(txn, to_string(encr->type), temp)) {
return;
}
}
std::visit(
[&txn, &statesdb, &stateskeydb, &eventsDb, &membersdb](const auto &e) {
@ -441,16 +445,20 @@ private:
{"id", e.event_id},
})
.dump());
} else if (e.state_key.empty())
} else if (e.state_key.empty()) {
statesdb.put(txn, to_string(e.type), nlohmann::json(e).dump());
else
stateskeydb.put(txn,
to_string(e.type),
nlohmann::json::object({
} else {
auto data = nlohmann::json::object({
{"key", e.state_key},
{"id", e.event_id},
})
.dump());
.dump();
auto key = to_string(e.type);
// Work around https://bugs.openldap.org/show_bug.cgi?id=8447
stateskeydb.del(txn, key, data);
stateskeydb.put(txn, key, data);
}
}
}
},

Loading…
Cancel
Save