Skip to content

Commit

Permalink
fix: [connection] validate full duplex on creation was broken
Browse files Browse the repository at this point in the history
  • Loading branch information
gallypette committed Jan 14, 2025
1 parent 1421126 commit bfe2640
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/cocktailparty/input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,18 @@ defmodule Cocktailparty.Input do
end

def validate_full_duplex(changeset) do
if ConnectionTypes.get_full_duplex(get_field(changeset, :type)) == true do
changeset
if get_change(changeset, :sink) do
if ConnectionTypes.get_full_duplex(get_field(changeset, :type)) == true do
changeset
else
add_error(
changeset,
:sink,
"This connection type does not support fullduplex connections"
)
end
else
add_error(changeset, :sink, "This connection type does not support fullduplex connections")
changeset
end
end

Expand All @@ -211,12 +219,8 @@ defmodule Cocktailparty.Input do
# We restart related processes if needed
if changed?(changeset, :config) do
connection =
if get_change(changeset, :sink) do
changeset
|> validate_full_duplex()
else
changeset
end

case Repo.update(connection) do
{:ok, connection} ->
Expand Down

0 comments on commit bfe2640

Please sign in to comment.