fix: properly pass actor into archive_related

This commit is contained in:
Zach Daniel 2024-02-20 11:21:22 -05:00
parent 55755caf65
commit 46cf71e53f

View file

@ -12,7 +12,6 @@ defmodule AshArchival.Resource.Changes.ArchiveRelated do
Ash.Changeset.after_action(changeset, fn changeset, result ->
# This is not optimized. We should do this with bulk queries, not resource actions.
opts = context |> Ash.context_to_opts()
{changeset.resource, context} |> IO.inspect()
loaded = changeset.api.load!(result, archive_related, opts)
notifications =
@ -27,7 +26,7 @@ defmodule AshArchival.Resource.Changes.ArchiveRelated do
|> List.wrap()
|> Enum.flat_map(fn related ->
related
|> Ash.Changeset.for_destroy(destroy_action, opts)
|> Ash.Changeset.for_destroy(destroy_action, %{}, opts)
|> (relationship.api || changeset.api).destroy!(
opts
|> Keyword.merge(return_notifications?: true)