You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rework the banning and unbanning of entities in PolicyLists. (#345)
* Rework the banning and unbanning of entities in PolicyLists.
1. We keep track of the event that created a list rule so that we
can remove the rule by having a way to determine the original state key for the rule.
This is because the state key of rules can be anything and should not be
relied on by Mjolnir to unban things (which it was doing).
2. The old scheme for producing a state key was causing for some entities to escape bans
#322.
We could have used a hash or something similar, but we know that
the reason for the `rule:${entity}` scheme existed was for ease of debugging
and finding rules in devtools. So instead we have followed a scheme simalar to
bridges where the first character of an mxid is replaced with an underscore.
Everything else just gets put into the state key. Since domains can't have '@'
and room ids, aliases can't either.
3. We have stopped the need for Mjolnir to wait for the next response from sync after banning,
unbanning an entity so that we can apply ACL's sooner.
* Use PolicyList's `banEntity` method to create imported rules.
@@ -328,15 +374,26 @@ class PolicyList extends EventEmitter {
328
374
}
329
375
}
330
376
this.emit('PolicyList.update',this,changes);
377
+
if(this.batchedEvents.keys.length!==0){
378
+
// The only reason why this isn't a TypeError is because we need to know about this when it happens, because it means
379
+
// we're probably doing something wrong, on the other hand, if someone messes with a server implementation and
380
+
// strange things happen where events appear in /sync sooner than they do in /state (which would be outrageous)
381
+
// we don't want Mjolnir to stop working properly. Though, I am not confident a burried warning is going to alert us.
382
+
LogService.warn("PolicyList","The policy list is being informed about events that it cannot find in the room state, this is really bad and you should seek help.");
383
+
}
331
384
returnchanges;
332
385
}
333
386
334
387
/**
335
388
* Inform the `PolicyList` about a new event from the room it is modelling.
336
389
* @param event An event from the room the `PolicyList` models to inform an instance about.
0 commit comments