2019-10-01 22:39:17 +00:00
|
|
|
defmodule ClacksWeb.InboxController do
|
|
|
|
use ClacksWeb, :controller
|
2019-10-02 01:59:43 +00:00
|
|
|
alias Clacks.Inbox
|
2019-10-01 22:39:17 +00:00
|
|
|
|
|
|
|
plug Plug.Parsers, parsers: [:urlencoded, :json], json_decoder: Jason
|
|
|
|
plug ClacksWeb.Plug.HTTPSignature
|
|
|
|
|
2019-10-02 01:59:43 +00:00
|
|
|
def shared(conn, _params) do
|
|
|
|
handle(conn, conn.body_params)
|
2019-10-01 22:39:17 +00:00
|
|
|
end
|
|
|
|
|
2019-10-02 01:59:43 +00:00
|
|
|
def user_specific(conn, _params) do
|
|
|
|
handle(conn, conn.body_params)
|
2019-10-01 22:39:17 +00:00
|
|
|
end
|
2019-10-02 01:59:43 +00:00
|
|
|
|
|
|
|
def handle(conn, %{"type" => "Create"} = activity) do
|
|
|
|
Inbox.handle_create(activity)
|
|
|
|
|
|
|
|
conn
|
|
|
|
|> put_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
def handle(conn, %{"type" => "Follow", "object" => object} = activity) when is_binary(object) do
|
|
|
|
Inbox.handle_follow(activity)
|
|
|
|
|
|
|
|
conn
|
|
|
|
|> put_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
# def handle(conn, _) do
|
|
|
|
# # todo: figure out how handle unhandled activity types
|
|
|
|
# end
|
2019-10-01 22:39:17 +00:00
|
|
|
end
|