]> kaliko git repositories - sid.git/blobdiff - sid/rtbl.py
rtbl: Fixed publish/retract item
[sid.git] / sid / rtbl.py
index 13e5c91332fcb485afea779cd092f4457a1dc783..0ea3bbbf36a8be446305595d36eeac78501e5795 100644 (file)
@@ -108,6 +108,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 +126,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 +139,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"""