Skip to content

Commit

Permalink
use command instead of full path
Browse files Browse the repository at this point in the history
  • Loading branch information
WanjikuMac committed Oct 31, 2023
1 parent b6b6c87 commit e5e7cdb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/twinklyhaha_web/controllers/oc2_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ defmodule TwinklyhahaWeb.OC2Controller do
def command(conn, params) do
params
|> Jason.encode!()
|> Openc2.Oc2.Command.new()
|> Openc2.Oc2.Command.do_cmd()
|> Command.new()
|> Command.do_cmd()
|> handle_response(conn)
end

defp handle_response(%Openc2.Oc2.Command{target: nil}, conn) do
defp handle_response(%Command{target: nil}, conn) do
send_resp(conn, :unprocessable_entity, "Oops! no target?")
end

defp handle_response(%Openc2.Oc2.Command{target: command}, conn) do
defp handle_response(%Command{target: command}, conn) do
Phoenix.PubSub.broadcast(Twinklyhaha.PubSub, @topic, command)
json(conn, %{status: :ok})
end
Expand Down

0 comments on commit e5e7cdb

Please sign in to comment.