dispatch method

Future<void> dispatch(
  1. List<NotificationConfig> notifications, {
  2. required bool succeeded,
  3. required String summary,
})

Sends every notification whose trigger matches the run outcome.

Delivery failures are reported but never change the exit code: a broken webhook must not turn a successful release into a failed one.

Implementation

Future<void> dispatch(
  List<NotificationConfig> notifications, {
  required bool succeeded,
  required String summary,
}) async {
  final pending = notifications
      .where(
          (notification) => notification.on.shouldFire(succeeded: succeeded))
      .toList();
  if (pending.isEmpty) return;

  for (final notification in pending) {
    await _send(notification, succeeded: succeeded, summary: summary);
  }
}