Verified Commit 01c2040f authored by Nicolas's avatar Nicolas

Remove unused variables

Set defaults and check room version validation
parent 35076e87
......@@ -2,14 +2,18 @@ defmodule PlasmaHS.RoomServer.Domain.CreateRoomRequest do
use Ecto.Schema
alias PlasmaHS.RoomServer.Domain.CreateRoomRequest
@matrix_config Application.get_env(:plasma, :matrix)
@default_room_version @matrix_config[:default_room_version]
@supported_room_versions @matrix_config[:supported_room_versions]
@visibilities ["public", "private"]
@presets ["private_chat", "public_chat", "trusted_private_chat"]
embedded_schema do
field :visibility, :string
field :sender_id, :binary_id
field :room_version, :string
field :creation_content, :map
field :room_version, :string, default: @default_room_version
field :creation_content, :map, default: %{}
field :power_level_content_override, :map
field :preset, :string
field :name, :string
......@@ -36,6 +40,7 @@ defmodule PlasmaHS.RoomServer.Domain.CreateRoomRequest do
|> Ecto.Changeset.validate_required([:sender_id])
|> Ecto.Changeset.validate_inclusion(:visibility, @visibilities, message: "bad_type")
|> Ecto.Changeset.validate_inclusion(:preset, @presets, message: "bad_type")
|> Ecto.Changeset.validate_inclusion(:room_version, @supported_room_versions, message: "unsupported_room_version")
|> Ecto.Changeset.apply_action(:insert)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment