Update to make the sync actions authorised for Book and Author.
This commit is contained in:
@@ -79,12 +79,11 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
|||||||
]
|
]
|
||||||
|
|
||||||
change fn changeset, context ->
|
change fn changeset, context ->
|
||||||
actor = Map.get(context, :actor, nil)
|
|
||||||
registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id)
|
registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id)
|
||||||
|
|
||||||
if registry_id == nil do
|
if registry_id == nil do
|
||||||
{:ok, registry} =
|
{: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)
|
Ash.Changeset.force_change_attribute(changeset, :author_alias_registry_id, registry.id)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user