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')
|
logging.debug('No fingerprint found in new message')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
msg_list = []
|
||||||
for old_message in self.messages():
|
for old_message in self.messages():
|
||||||
try:
|
try:
|
||||||
old_fingerprint = old_message['extras']['alertify']['fingerprint']
|
old_fingerprint = old_message['extras']['alertify']['fingerprint']
|
||||||
if old_fingerprint == new_fingerprint:
|
if old_fingerprint == new_fingerprint:
|
||||||
return old_message['id']
|
msg_list.append(old_message['id'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.debug(
|
logging.warning(
|
||||||
'No fingerprint found in message ID: %s',
|
'No fingerprint found in message ID: %s',
|
||||||
old_message['id'],
|
old_message['id'],
|
||||||
)
|
)
|
||||||
continue
|
|
||||||
|
|
||||||
logging.debug('No fingerprint matched.')
|
return msg_list
|
||||||
return None
|
|
||||||
|
|
||||||
def messages(self):
|
def messages(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -28,10 +28,9 @@ class MessageHandler:
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.delete_onresolve:
|
if self.delete_onresolve:
|
||||||
alert_id = self.gotify.find_byfingerprint(alert)
|
for alert_id in self.gotify.find_byfingerprint(alert):
|
||||||
if alert_id:
|
if not self.gotify.delete(alert_id):
|
||||||
return self.gotify.delete(alert_id)
|
logging.error('There was a problem removing message ID %d', alert_id)
|
||||||
logging.warning('Could not find a matching message to delete.')
|
|
||||||
|
|
||||||
prefix = 'resolved'
|
prefix = 'resolved'
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue