 
   def secret, do: Application.get_env(:admin, :osdi_api_token)
 
-  def internal_events_api(conn, %{"secret" => input_secret}) do
+  def internal_events_api(conn, params = %{"secret" => input_secret}) do
     if secret() == input_secret do
       events =
         OsdiClient.stream(client(), "events")
         |> Enum.map(&Admin.EventsChannel.event_pipeline/1)
+        |> Enum.filter(fn ev -> if params["future"], do: is_in_future?(ev), else: true end)
+        |> Enum.filter(fn ev ->
+          if params["confirmed"], do: ev.status == "confirmed", else: true
+        end)
         |> Enum.map(fn ev ->
-          tags = Map.get(ev, "tags", [])
+          tags = Map.get(ev, :tags, [])
 
           candidate_tag =
             Enum.filter(

    text(conn, "Missing secret – please visit /api/events?secret=thethingigotfromben")
  end

  def client,
    do:
      OsdiClient.build_client(

              "Calendar: " <> c -> c
            end

          flags =
            %{}
            |> Map.put("direct_publish", Enum.member?(tags, "Source: Direct Publish"))
            |> Map.put("synced", Enum.member?(tags, "Source: Sync"))
            |> Map.put("editable", not Enum.member?(tags, "Source: Sync"))
            |> Map.put("local_chapter", Enum.member?(tags, "Calendar: Local Chapter"))
            |> Map.put("candidate", candidate)

          Map.merge(ev, flags)
        end)

      json(conn, events)
