]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Fixing PostfixLogfileParser because of pickup data
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 10 Apr 2024 15:02:45 +0000 (17:02 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 10 Apr 2024 15:02:45 +0000 (17:02 +0200)
lib/pp_admintools/handler/pflogparse.py

index 5f13b7be0425b5a64905b9717c9726499b0b4788..b1d63c91a2d274c8e9b83533a877a45adf5c8861 100644 (file)
@@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-__version__ = '0.5.1'
+__version__ = '0.5.2'
 
 
 # =============================================================================
@@ -345,19 +345,21 @@ class PostfixLogfileParser(HandlingObject):
                         LOG.debug(msg)
                 return
 
-        if command == 'postfix/cleanup':
+        if command == 'postfix/pickup':
             m = self.re_pickup.search(message)
             if m:
                 if postfix_id in self.chain:
                     self.chain[postfix_id].pickup_from = m['from']
                     self.chain[postfix_id].pickup_uid = m['uid']
                 else:
-                    msg = _('Did not found Postfix ID {!r} for pickup log entry.').format(
-                        postfix_id)
-                    if self.warn_on_parse_error:
-                        LOG.warn(msg)
-                    else:
-                        LOG.debug(msg)
+                    chain = PostfixLogchainInfo(
+                        start=timestamp,
+                        postfix_id=postfix_id,
+                        smtpd_pid=pid,
+                        pickup_from=m['from'],
+                        pickup_uid=m['uid'],
+                    )
+                    self.chain[postfix_id] = chain
                 return
 
         if command == 'opendkim':
@@ -383,7 +385,16 @@ class PostfixLogfileParser(HandlingObject):
             if m:
                 bid = m['bounce_id'].strip()
                 if bid:
-                    self.chain[postfix_id].add_bounce_id(bid)
+                    if postfix_id in self.chain:
+                        self.chain[postfix_id].add_bounce_id(bid)
+                    else:
+                        msg = _(
+                            'Did not found Postfix ID {pfid!r} for Bounce ID {bid!r}.').format(
+                            pfid=postfix_id, bid=bid)
+                        if self.warn_on_parse_error:
+                            LOG.warn(msg)
+                        else:
+                            LOG.debug(msg)
                     return
 
         if self.verbose > 1: