Refactor notification urgency handling in notify_event method

Previously, the `notify_event` method had a parameter named `critical` to determine the urgency of the notification. This has been changed to `urgent` for clarity. The method now uses the `urgent` parameter directly in the `self.notify` call instead of converting it to an "urgency" string. This commit refactors the code to improve readability and maintainability.
This commit is contained in:
Kumi 2023-09-13 09:30:31 +02:00
parent 2eca302234
commit 074ddd1edb
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -143,14 +143,14 @@ class Core:
for notifier in self.notifiers: for notifier in self.notifiers:
notifier.notify(title, message, urgent) notifier.notify(title, message, urgent)
def notify_event(self, shipment, event, critical=False) -> None: def notify_event(self, shipment, event, urgent=False) -> None:
logging.info( logging.info(
f"New event for {shipment.tracking_number}: {event.event_description} - {event.event_time}" f"New event for {shipment.tracking_number}: {event.event_description} - {event.event_time}"
) )
self.notify( self.notify(
f"New event for {shipment.description or shipment.tracking_number}", f"New event for {shipment.description or shipment.tracking_number}",
event.event_description + " - " + event.event_time, event.event_description + " - " + event.event_time,
urgency="critical" if critical else "normal", urgent=urgent,
) )
def process_shipment(self, shipment) -> None: def process_shipment(self, shipment) -> None: