@@ -48,9 +48,6 @@ func (pe *PolicyEvaluator) ApplyPolicy(ctx context.Context, userID id.UserID, po
48
48
Any ("matches" , policy ).
49
49
Msg ("Applying ban recommendation" )
50
50
pe .policyServer .UpdateRecommendation (userID , pe .GetProtectedRooms (), PSRecommendationSpam )
51
- for _ , room := range rooms {
52
- pe .ApplyBan (ctx , userID , room , recs .BanOrUnban )
53
- }
54
51
shouldRedact := recs .BanOrUnban .Recommendation == event .PolicyRecommendationUnstableTakedown
55
52
if ! shouldRedact && recs .BanOrUnban .Reason != "" {
56
53
for _ , pattern := range pe .autoRedactPatterns {
@@ -60,6 +57,9 @@ func (pe *PolicyEvaluator) ApplyPolicy(ctx context.Context, userID id.UserID, po
60
57
}
61
58
}
62
59
}
60
+ for _ , room := range rooms {
61
+ pe .ApplyBan (ctx , userID , room , recs .BanOrUnban , shouldRedact )
62
+ }
63
63
if shouldRedact {
64
64
go pe .RedactUser (context .WithoutCancel (ctx ), userID , recs .BanOrUnban .Reason , true )
65
65
}
@@ -149,7 +149,13 @@ func (pe *PolicyEvaluator) maybeApplySuspend(ctx context.Context, userID id.User
149
149
}
150
150
}
151
151
152
- func (pe * PolicyEvaluator ) ApplyBan (ctx context.Context , userID id.UserID , roomID id.RoomID , policy * policylist.Policy ) {
152
+ func (pe * PolicyEvaluator ) ApplyBan (
153
+ ctx context.Context ,
154
+ userID id.UserID ,
155
+ roomID id.RoomID ,
156
+ policy * policylist.Policy ,
157
+ shouldRedact bool ,
158
+ ) {
153
159
ta := & database.TakenAction {
154
160
TargetUser : userID ,
155
161
InRoomID : roomID ,
@@ -164,6 +170,8 @@ func (pe *PolicyEvaluator) ApplyBan(ctx context.Context, userID id.UserID, roomI
164
170
_ , err = pe .Bot .BanUser (ctx , roomID , & mautrix.ReqBanUser {
165
171
Reason : filterReason (policy .Reason ),
166
172
UserID : userID ,
173
+
174
+ MSC4293RedactEvents : shouldRedact ,
167
175
})
168
176
}
169
177
if err != nil {
0 commit comments