From 93ae8f17a533070ceff78d48e092d6f2add1c76d Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Sun, 25 Feb 2024 16:13:41 -0500 Subject: [PATCH] fix: handle small logic error in notification sending for bulk actions --- lib/ash/actions/destroy/bulk.ex | 14 +++++++++----- lib/ash/actions/update/bulk.ex | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/ash/actions/destroy/bulk.ex b/lib/ash/actions/destroy/bulk.ex index a02e724f..9ec30a9b 100644 --- a/lib/ash/actions/destroy/bulk.ex +++ b/lib/ash/actions/destroy/bulk.ex @@ -427,14 +427,18 @@ defmodule Ash.Actions.Destroy.Bulk do {Enum.reverse(errors), Enum.reverse(successes), notifications, error_count} end) else - {[], results, [], 0} + {[], results || [], [], 0} end notifications = - notifications ++ - Enum.map(results, fn result -> - notification(atomic_changeset, result, opts) - end) + if opts[:notify?] do + notifications ++ + Enum.map(results, fn result -> + notification(atomic_changeset, result, opts) + end) + else + notifications + end status = case {error_count, results} do diff --git a/lib/ash/actions/update/bulk.ex b/lib/ash/actions/update/bulk.ex index b8af0133..7d8da3ef 100644 --- a/lib/ash/actions/update/bulk.ex +++ b/lib/ash/actions/update/bulk.ex @@ -384,7 +384,7 @@ defmodule Ash.Actions.Update.Bulk do {Enum.reverse(errors), Enum.reverse(successes), notifications, error_count} end) else - {[], results, [], 0} + {[], results || [], [], 0} end {results, errors, error_count} = @@ -403,10 +403,14 @@ defmodule Ash.Actions.Update.Bulk do end notifications = - notifications ++ - Enum.map(results, fn result -> - notification(atomic_changeset, result, opts) - end) + if opts[:notify?] do + notifications ++ + Enum.map(results, fn result -> + notification(atomic_changeset, result, opts) + end) + else + notifications + end status = case {error_count, results} do