From 61fd55e9c0e2246bf76fe95c8382a562da0a214b Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 3 Mar 2022 21:20:53 +0100 Subject: [PATCH] add handler callback for ?q=channel requests --- lib/plug_micropub.ex | 9 +++++++++ lib/plug_micropub/handler_behaviour.ex | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/lib/plug_micropub.ex b/lib/plug_micropub.ex index 5e0332e..92901d0 100644 --- a/lib/plug_micropub.ex +++ b/lib/plug_micropub.ex @@ -215,6 +215,15 @@ defmodule PlugMicropub do end end + defp handle_query(:channel, access_token, conn) do + handler = conn.private[:plug_micropub][:handler] + + case handler.handle_channel_query(access_token) do + {:ok, content} -> send_content(conn, content) + error -> send_error(conn, error) + end + end + defp parse_update_properties(properties) do properties = Map.take(properties, ["replace", "add", "delete"]) diff --git a/lib/plug_micropub/handler_behaviour.ex b/lib/plug_micropub/handler_behaviour.ex index e324d8d..c5733e5 100644 --- a/lib/plug_micropub/handler_behaviour.ex +++ b/lib/plug_micropub/handler_behaviour.ex @@ -44,6 +44,10 @@ defmodule PlugMicropub.HandlerBehaviour do {:ok, map} | handler_error + @callback handle_channel_query(access_token) :: + {:ok, map} + | handler_error + @callback handle_source_query( url :: String.t(), properties :: [String.t()],