|
|
@ -78,11 +78,10 @@ defmodule DecentralisedBookIndex.Metadata.Book do
|
|
|
|
argument :author_roles, {:array, :map}
|
|
|
|
argument :author_roles, {:array, :map}
|
|
|
|
|
|
|
|
|
|
|
|
change fn changeset, context ->
|
|
|
|
change fn changeset, context ->
|
|
|
|
actor = Map.get(context, :actor, nil)
|
|
|
|
|
|
|
|
registry_id = Ash.Changeset.get_attribute(changeset, :book_editions_registry_id)
|
|
|
|
registry_id = Ash.Changeset.get_attribute(changeset, :book_editions_registry_id)
|
|
|
|
|
|
|
|
|
|
|
|
if registry_id == nil do
|
|
|
|
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)
|
|
|
|
Ash.Changeset.force_change_attribute(changeset, :book_editions_registry_id, registry.id)
|
|
|
|
else
|
|
|
|
else
|
|
|
|