Update to make the sync actions authorised for Book and Author.

dev
KKlochko 2 months ago
parent e078bf0911
commit f40af2bc76

@ -79,12 +79,11 @@ defmodule DecentralisedBookIndex.Metadata.Author do
]
change fn changeset, context ->
actor = Map.get(context, :actor, nil)
registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id)
if registry_id == nil do
{:ok, registry} =
DecentralisedBookIndex.Metadata.create_author_alias_registry(actor: actor)
DecentralisedBookIndex.Metadata.create_author_alias_registry(authorize?: false)
Ash.Changeset.force_change_attribute(changeset, :author_alias_registry_id, registry.id)
else

@ -78,11 +78,10 @@ defmodule DecentralisedBookIndex.Metadata.Book do
argument :author_roles, {:array, :map}
change fn changeset, context ->
actor = Map.get(context, :actor, nil)
registry_id = Ash.Changeset.get_attribute(changeset, :book_editions_registry_id)
if registry_id == nil do
registry = DecentralisedBookIndex.Metadata.create_book_editions_registry!(actor: actor)
registry = DecentralisedBookIndex.Metadata.create_book_editions_registry!(authorize?: false)
Ash.Changeset.force_change_attribute(changeset, :book_editions_registry_id, registry.id)
else

Loading…
Cancel
Save