~afontaine/home unlisted

aa79848d8b3b58da89e43d2900d1e882695f1e85 — Andrew Fontaine 3 months ago 4f5d50f
Match On Post Creation

Matching will blow up on error, hopefully giving us a stack trace.

Also log out the new post _just to be sure._
2 files changed, 16 insertions(+), 9 deletions(-)

M apps/home_web/lib/home_web/controllers/receive_controller.ex
M flake.nix
M apps/home_web/lib/home_web/controllers/receive_controller.ex => apps/home_web/lib/home_web/controllers/receive_controller.ex +15 -8
@@ 1,18 1,25 @@
defmodule HomeWeb.ReceiveController do
  use HomeWeb, :controller
  require Logger

  alias Blog.Mail
  alias Blog.Content

  def receive(conn, post) do
    case Mail.create_post(post) do
      {:ok, post} ->
        post
        |> Map.from_struct()
        |> Content.create_post()
    {:ok, post} =
      case Mail.create_post(post) do
        {:ok, post} ->
          post
          |> Map.from_struct()
          |> Content.create_post()

        x ->
          raise x
      end

      x ->
        raise x
    end
    Logger.info(fn ->
      "New post: #{inspect(post)}"
    end)

    conn
    |> put_status(:ok)

M flake.nix => flake.nix +1 -1
@@ 77,7 77,7 @@
          '';
        };
        packages = let
          version = "0.1.1";
          version = "0.1.2";
          src = ./.;
        in flake-utils.lib.flattenTree {
          home-elixir-deps = erlangPackages.fetchMixDeps {