Add the avatar_url attribute to Author's create action.
This commit is contained in:
@@ -46,11 +46,11 @@ defmodule DecentralisedBookIndex.Metadata do
|
||||
resource DecentralisedBookIndex.Metadata.Author do
|
||||
define :create_author,
|
||||
action: :create,
|
||||
args: [:name, :description, {:optional, :author_alias_registry_id}]
|
||||
args: [:name, :description, {:optional, :avatar_url}, {:optional, :author_alias_registry_id}]
|
||||
|
||||
define :add_author_to_related_alias_registry,
|
||||
action: :add_author_to_related_alias_registry,
|
||||
args: [:name, :description, :related_author_id]
|
||||
args: [:name, :description, :related_author_id, {:optional, :avatar_url}]
|
||||
|
||||
define :list_authors, action: :read
|
||||
define :get_author_by_id, args: [:id], action: :by_id
|
||||
|
||||
@@ -22,7 +22,7 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
||||
|
||||
create :create do
|
||||
primary? true
|
||||
accept [:name, :description, :author_alias_registry_id]
|
||||
accept [:name, :description, :avatar_url, :author_alias_registry_id]
|
||||
|
||||
change fn changeset, _ ->
|
||||
registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id)
|
||||
@@ -38,7 +38,7 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
||||
end
|
||||
|
||||
create :add_author_to_related_alias_registry do
|
||||
accept [:name, :description]
|
||||
accept [:name, :description, :avatar_url]
|
||||
|
||||
argument :related_author_id, :uuid do
|
||||
allow_nil? false
|
||||
@@ -63,7 +63,7 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
||||
end
|
||||
|
||||
create :sync do
|
||||
accept [:id, :name, :description, :dbi_server_id, :author_alias_registry_id]
|
||||
accept [:id, :name, :description, :avatar_url, :dbi_server_id, :author_alias_registry_id]
|
||||
|
||||
change fn changeset, _ ->
|
||||
server_id = Ash.Changeset.get_attribute(changeset, :dbi_server)
|
||||
|
||||
@@ -9,12 +9,14 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformer do
|
||||
id: get_in(json_body, ["data", "id"]),
|
||||
name: get_in(json_body, ["data", "attributes", "name"]),
|
||||
description: get_in(json_body, ["data", "attributes", "description"]),
|
||||
avatar_url: get_in(json_body, ["data", "attributes", "avatar_url"]),
|
||||
}
|
||||
else
|
||||
%{
|
||||
id: get_in(json_body, ["id"]),
|
||||
name: get_in(json_body, ["attributes", "name"]),
|
||||
description: get_in(json_body, ["attributes", "description"]),
|
||||
avatar_url: get_in(json_body, ["attributes", "avatar_url"]),
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user