fix celeryscript ast encodeing.

This commit is contained in:
connor rigby 2017-11-13 12:29:34 -08:00
parent b782fb5f7e
commit a67508eac5
2 changed files with 7 additions and 4 deletions

View file

@ -193,8 +193,8 @@ defmodule Farmbot.BotState do
@doc "Emit an AST." @doc "Emit an AST."
def emit(%AST{} = ast) do def emit(%AST{} = ast) do
kind = Module.split(ast.kind) |> List.last |> Macro.underscore() # kind = Module.split(ast.kind) |> List.last |> Macro.underscore()
GenStage.call(__MODULE__, {:emit, %{ast | kind: kind}}) GenStage.call(__MODULE__, {:emit, ast})
end end
@doc "Get user env." @doc "Get user env."

View file

@ -148,8 +148,11 @@ defmodule Farmbot.BotState.Transport.AMQP do
end end
defp emit_cs(chan, bot, cs) do defp emit_cs(chan, bot, cs) do
json = Poison.encode!(cs) with {:ok, map} <- Farmbot.CeleryScript.AST.encode(cs),
:ok = AMQP.Basic.publish chan, @exchange, "bot.#{bot}.from_device", json {:ok, json} <- Poison.encode(map)
do
:ok = AMQP.Basic.publish chan, @exchange, "bot.#{bot}.from_device", json
end
end end
defp push_bot_state(chan, bot, state) do defp push_bot_state(chan, bot, state) do