diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-03-26 23:37:28 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-03-26 23:37:28 +0200 |
commit | c543b2d4fa8eb3a39a12c0620385ccc155bc06dd (patch) | |
tree | 454f5b7003ad6b81d50b20b5a240e3e2618bb21e /src/Cache_p.h | |
parent | Use gitlab docker proxy (diff) | |
download | nheko-c543b2d4fa8eb3a39a12c0620385ccc155bc06dd.tar.xz |
Improve state event redaction
Diffstat (limited to '')
-rw-r--r-- | src/Cache_p.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/Cache_p.h b/src/Cache_p.h index 69e99fa0..cc016d4b 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h @@ -436,11 +436,22 @@ private: if (e.type != EventType::Unsupported) { if (std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(e)>>, StateEvent<mtx::events::msg::Redacted>>) { - if (e.type == EventType::RoomMember) - membersdb.del(txn, e.state_key, ""); - else if (e.state_key.empty()) - statesdb.del(txn, to_string(e.type)); - else + // apply the redaction event + if (e.type == EventType::RoomMember) { + // membership is not revoked, but names are yeeted (so we set the name + // to the mxid) + MemberInfo tmp{e.state_key, ""}; + membersdb.put(txn, e.state_key, nlohmann::json(tmp).dump()); + } else if (e.state_key.empty()) { + // strictly speaking some stuff in those events can be redacted, but + // this is close enough. Ref: + // https://spec.matrix.org/v1.6/rooms/v10/#redactions + if (e.type != EventType::RoomCreate && + e.type != EventType::RoomJoinRules && + e.type != EventType::RoomPowerLevels && + e.type != EventType::RoomHistoryVisibility) + statesdb.del(txn, to_string(e.type)); + } else stateskeydb.del( txn, to_string(e.type), e.state_key + '\0' + e.event_id); } else if (e.state_key.empty()) { |