X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sid%2Frtbl.py;h=b5c58cbef662635c5105572f3812d47d4903547f;hb=a8273fcb65b081ee9ebda42a0f39f071850d8f66;hp=13e5c91332fcb485afea779cd092f4457a1dc783;hpb=cf4e0e61fd723ec820449c6dd26a820514404c63;p=sid.git diff --git a/sid/rtbl.py b/sid/rtbl.py index 13e5c91..b5c58cb 100644 --- a/sid/rtbl.py +++ b/sid/rtbl.py @@ -21,9 +21,11 @@ def jid_to_sha256(jid: JID) -> str: class BL: """Plain object to keep track of block list items. Only used in RTBL plugin.""" + #: Initial seed to ease testing + init = {} def __init__(self, initial_bl): - self.sha256_jids: Dict[str, Optional[str]] = {} + self.sha256_jids: Dict[str, Optional[str]] = dict(BL.init) for item in initial_bl: self.insert_item(item) @@ -108,6 +110,9 @@ class RTBL(Plugin): self.blocklist = BL(node_blocklist['pubsub']['items']) mess = f'Got {len(self.blocklist)} items in block list' self.log.info(mess) + # Are current participants in the block list + for jid in list(self.participants): + await self.rtbl_ban(jid) async def _create(self): """Try to create node""" @@ -123,7 +128,7 @@ class RTBL(Plugin): self.log.debug('Retracted item %s from %s' % ( msg['pubsub_event']['items']['retract']['id'], msg['pubsub_event']['items']['node'])) - self.blocklist.retract_item(msg['pubsub_event']['items']['retract']['id']) + self.blocklist.retract_item(msg['pubsub_event']['items']['retract']) async def _publish(self, msg): """Handler receiving a publish item event.""" @@ -136,10 +141,10 @@ class RTBL(Plugin): else: self.log.debug('No item content') return - self.blocklist.insert_item(msg['pubsub_event']['items']['item']['id']) + self.blocklist.insert_item(msg['pubsub_event']['items']['item']) # Are current participants in the block list - for jid in self.participants: - self.rtbl_ban(jid) + for jid in list(self.participants): + await self.rtbl_ban(jid) async def rtbl_ban(self, jid): """Ban jid in RTBL"""