I'm creating a chat app and I have a bunch of channel messages. Here's one of them:
def handle_in("read", %{ "chat_id" => chat_id }, socket) do
user_id = socket.assigns[:id]
ts = DateTime.utc_now
case ChatManager.mark_as_read({user_id, chat_id, ts}) do
{:ok, chat_user} ->
last_read_at_unix = chat_user.last_read_at |> TimeConverter.ecto_to_unix
{:reply, {:ok, %{ chat_id: chat_id, last_read_at: last_read_at_unix }}, socket}
{:error, changeset} ->
{:reply, {:error, %{errors: changeset.errors}}, socket}
end
end
Can I use phoenix Views to separate my presentation / response logic? This way I can just quickly go to a view file and see what is returned by each message.