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

This commit is contained in:
Nicolas Werner 2023-02-25 23:47:07 +01:00
parent d8df6de6ab
commit 9399e68fda
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -412,13 +412,17 @@ private:
break; break;
} }
} }
} else if (auto encr = std::get_if<StateEvent<Encryption>>(&event)) {
if (!encr->state_key.empty())
return;
// 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!
return;
} else if (std::holds_alternative<StateEvent<Encryption>>(event)) {
setEncryptedRoom(txn, room_id); setEncryptedRoom(txn, room_id);
return;
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( std::visit(
@ -441,16 +445,20 @@ private:
{"id", e.event_id}, {"id", e.event_id},
}) })
.dump()); .dump());
} else if (e.state_key.empty()) } else if (e.state_key.empty()) {
statesdb.put(txn, to_string(e.type), nlohmann::json(e).dump()); statesdb.put(txn, to_string(e.type), nlohmann::json(e).dump());
else } else {
stateskeydb.put(txn, auto data = nlohmann::json::object({
to_string(e.type), {"key", e.state_key},
nlohmann::json::object({ {"id", e.event_id},
{"key", e.state_key}, })
{"id", e.event_id}, .dump();
}) auto key = to_string(e.type);
.dump());
// Work around https://bugs.openldap.org/show_bug.cgi?id=8447
stateskeydb.del(txn, key, data);
stateskeydb.put(txn, key, data);
}
} }
} }
}, },