defmodule ClacksWeb.ObjectsController do use ClacksWeb, :controller alias Clacks.{Repo, Object, ActivityPub} import Ecto.Query def get(conn, %{"id" => id}) do object_id = current_url(conn) query = from(o in Object, where: fragment("?->>'id'", o.data) == ^object_id) case Repo.one(query) do nil -> conn |> put_status(404) object -> conn |> put_resp_header("content-type", "application/activity+json") |> json(object.data) end end end