Files
wanderer/lib/wanderer_app/api/map_invite.ex
Dmitry Popov 083e300ff5
Some checks failed
Build Test / 🚀 Deploy to test env (fly.io) (push) Has been cancelled
Build Test / 🛠 Build (1.17, 18.x, 27) (push) Has been cancelled
Build Develop / 🛠 Build (1.17, 18.x, 27) (push) Has been cancelled
🧪 Test Suite / Test Suite (push) Has been cancelled
Build Develop / 🛠 Build Docker Images (linux/amd64) (push) Has been cancelled
Build Develop / 🛠 Build Docker Images (linux/arm64) (push) Has been cancelled
Build Develop / merge (push) Has been cancelled
Build Develop / 🏷 Notify about develop release (push) Has been cancelled
chore: updated deps, fixed signatures and comments related issues
2025-11-21 14:23:44 +01:00

97 lines
1.5 KiB
Elixir

defmodule WandererApp.Api.MapInvite do
@moduledoc false
use Ash.Resource,
domain: WandererApp.Api,
data_layer: AshPostgres.DataLayer
postgres do
repo(WandererApp.Repo)
table("map_invites_v1")
end
code_interface do
define(:new, action: :new)
define(:read, action: :read)
define(:destroy, action: :destroy)
define(:by_id,
get_by: [:id],
action: :read
)
define(:by_map,
action: :by_map
)
end
actions do
default_accept [
:token
]
defaults [:read, :destroy]
update :update do
require_atomic? false
end
create :new do
accept [
:map_id,
:token,
:type,
:valid_until
]
primary?(true)
end
read :by_map do
argument(:map_id, :string, allow_nil?: false)
filter(expr(map_id == ^arg(:map_id)))
end
end
attributes do
uuid_primary_key :id
attribute :token, :string do
allow_nil? true
end
attribute :type, :atom do
default "user"
constraints(
one_of: [
:user,
:admin
]
)
allow_nil?(false)
end
attribute :valid_until, :utc_datetime do
allow_nil? true
end
create_timestamp(:inserted_at)
update_timestamp(:updated_at)
end
relationships do
belongs_to :map, WandererApp.Api.Map do
attribute_writable? true
end
end
postgres do
references do
reference :map, on_delete: :delete
end
end
end