Skip to content

Commit 0256f58

Browse files
committed
1 parent 3c1c62d commit 0256f58

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Quotient/events/redactionevent.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "roomevent.h"
77

88
namespace Quotient {
9+
constexpr inline auto RedactsKey = "redacts"_L1;
10+
911
class QUOTIENT_API RedactionEvent : public RoomEvent {
1012
public:
1113
QUO_EVENT(RedactionEvent, "m.room.redaction")
@@ -19,14 +21,19 @@ class QUOTIENT_API RedactionEvent : public RoomEvent {
1921
}
2022
QStringList redactedEvents() const
2123
{
22-
const auto evtIdJson = contentJson()["redacts"_ls];
24+
const auto evtIdJson = contentJson()["redacts"_L1];
2325
if (evtIdJson.isArray())
2426
return fromJson<QStringList>(evtIdJson); // MSC2244: a list of ids
2527
if (evtIdJson.isString())
2628
return { fromJson<QString>(evtIdJson) }; // MSC2174: id in content
27-
return { fullJson()["redacts"_ls].toString() }; // legacy fallback
29+
return { fullJson()["redacts"_L1].toString() }; // legacy fallback
2830
}
2931

3032
QUO_CONTENT_GETTER(QString, reason)
3133
};
34+
35+
QUO_DEFINE_SIMPLE_EVENT(RedactionsEvent, RoomEvent,
36+
QUO_LIST("org.matrix.msc4343.redactions", "m.room.redactions"), QStringList,
37+
redactedEvents, RedactsKey)
38+
3239
} // namespace Quotient

Quotient/room.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,17 +2720,14 @@ RoomEventPtr makeRedacted(const RoomEvent& target,
27202720
}
27212721
if (!target.is<RoomCreateEvent>()) { // See MSC2176 on create events
27222722
static const QHash<QString, QStringList> ContentKeysToKeepPerType{
2723-
{ RedactionEvent::TypeId, { "redacts"_L1 } },
2724-
{ RoomMemberEvent::TypeId,
2725-
{ "membership"_L1, "join_authorised_via_users_server"_L1 } },
2726-
{ RoomPowerLevelsEvent::TypeId,
2727-
{ "ban"_L1, "events"_L1, "events_default"_L1, "invite"_L1,
2728-
"kick"_L1, "redact"_L1, "state_default"_L1, "users"_L1,
2729-
"users_default"_L1 } },
2730-
// TODO: Replace with RoomJoinRules::TypeId etc. once available
2731-
{ "m.room.join_rules"_L1, { "join_rule"_L1, "allow"_L1 } },
2732-
{ "m.room.history_visibility"_L1, { "history_visibility"_L1 } }
2733-
};
2723+
{RedactionEvent::TypeId, {RedactsKey}},
2724+
{RoomMemberEvent::TypeId, {"membership"_L1, "join_authorised_via_users_server"_L1}},
2725+
{RoomPowerLevelsEvent::TypeId,
2726+
{"ban"_L1, "events"_L1, "events_default"_L1, "invite"_L1, "kick"_L1, "redact"_L1,
2727+
"state_default"_L1, "users"_L1, "users_default"_L1}},
2728+
{JoinRulesEvent::TypeId, {"join_rule"_L1, "allow"_L1}},
2729+
// TODO: Replace with ::TypeId once available
2730+
{"m.room.history_visibility"_L1, {"history_visibility"_L1}}};
27342731

27352732
if (const auto contentKeysToKeep = ContentKeysToKeepPerType.value(target.matrixType());
27362733
!contentKeysToKeep.isEmpty()) //

0 commit comments

Comments
 (0)