mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-07-01 00:51:36 +00:00
Wrap ban list build in a logging context
This commit is contained in:
parent
f72b68dc7c
commit
83fffd322e
|
@ -16,6 +16,7 @@
|
|||
import logging
|
||||
from .list_rule import ListRule, ALL_RULE_TYPES, USER_RULE_TYPES, SERVER_RULE_TYPES, ROOM_RULE_TYPES
|
||||
from twisted.internet import defer
|
||||
from synapse.logging.context import LoggingContext
|
||||
|
||||
logger = logging.getLogger("synapse.contrib." + __name__)
|
||||
|
||||
|
@ -28,8 +29,9 @@ class BanList(object):
|
|||
self.room_rules = []
|
||||
self.build()
|
||||
|
||||
def build(with_event=None):
|
||||
@defer.inlineCallbacks
|
||||
def build(self, with_event=None):
|
||||
def run(self, with_event=None):
|
||||
events = yield self.get_relevant_state_events()
|
||||
if with_event is not None:
|
||||
events = [*events, with_event]
|
||||
|
@ -68,5 +70,8 @@ class BanList(object):
|
|||
elif event_type in SERVER_RULE_TYPES:
|
||||
self.server_rules.append(rule)
|
||||
|
||||
with LoggingContext("mjolnir_ban_list_build"):
|
||||
run(with_event=with_event)
|
||||
|
||||
def get_relevant_state_events(self):
|
||||
return self.api.get_state_events_in_room(self.room_id, [(t, None) for t in ALL_RULE_TYPES])
|
||||
|
|
Loading…
Reference in New Issue
Block a user