diff --git a/src/alertify/gotify.py b/src/alertify/gotify.py index f298b35..2ae6e0a 100644 --- a/src/alertify/gotify.py +++ b/src/alertify/gotify.py @@ -77,20 +77,19 @@ class Gotify: logging.debug('No fingerprint found in new message') return None + msg_list = [] for old_message in self.messages(): try: old_fingerprint = old_message['extras']['alertify']['fingerprint'] if old_fingerprint == new_fingerprint: - return old_message['id'] + msg_list.append(old_message['id']) except KeyError: - logging.debug( + logging.warning( 'No fingerprint found in message ID: %s', old_message['id'], ) - continue - logging.debug('No fingerprint matched.') - return None + return msg_list def messages(self): """ diff --git a/src/alertify/messaging.py b/src/alertify/messaging.py index eb4778e..fb03764 100644 --- a/src/alertify/messaging.py +++ b/src/alertify/messaging.py @@ -28,10 +28,9 @@ class MessageHandler: } if self.delete_onresolve: - alert_id = self.gotify.find_byfingerprint(alert) - if alert_id: - return self.gotify.delete(alert_id) - logging.warning('Could not find a matching message to delete.') + for alert_id in self.gotify.find_byfingerprint(alert): + if not self.gotify.delete(alert_id): + logging.error('There was a problem removing message ID %d', alert_id) prefix = 'resolved' else: