def _send( self, notification_content: NotificationContent, recipients: List[ReportRecipients], ) -> None: """ Sends a notification to all recipients :raises: ReportScheduleNotificationError """ notification_errors = [] for recipient in recipients: notification = create_notification(recipient, notification_content) try: if app.config["ALERT_REPORTS_NOTIFICATION_DRY_RUN"]: logger.info( "Would send notification for alert %s, to %s", self._report_schedule.name, recipient.recipient_config_json, ) else: notification.send() except NotificationError as ex: # collect notification errors but keep processing them notification_errors.append(str(ex)) if notification_errors: raise ReportScheduleNotificationError( ";".join(notification_errors))
def _send(self, notification_content: NotificationContent) -> None: """ Sends a notification to all recipients :raises: ReportScheduleNotificationError """ notification_errors = [] for recipient in self._report_schedule.recipients: notification = create_notification(recipient, notification_content) try: notification.send() except NotificationError as ex: # collect notification errors but keep processing them notification_errors.append(str(ex)) if notification_errors: raise ReportScheduleNotificationError(";".join(notification_errors))
def _send(self, report_schedule: ReportSchedule) -> None: """ Creates the notification content and sends them to all recipients :raises: ReportScheduleNotificationError """ notification_errors = [] notification_content = self._get_notification_content(report_schedule) for recipient in report_schedule.recipients: notification = create_notification(recipient, notification_content) try: notification.send() except NotificationError as ex: # collect notification errors but keep processing them notification_errors.append(str(ex)) if notification_errors: raise ReportScheduleNotificationError(";".join(notification_errors))