Resolves #18: Ensure all matching messages are removed, if enabled
This commit is contained in:
parent
a6aad06dac
commit
3c9128c233
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue