Merge pull request 'Update development docs' (#43) from norm/akkoma:docs-development...
[akkoma] / lib / pleroma / web / uploader_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.UploaderController do
6 use Pleroma.Web, :controller
7
8 alias Pleroma.Uploaders.Uploader
9
10 def callback(conn, %{"upload_path" => upload_path} = params) do
11 process_callback(conn, :global.whereis_name({Uploader, upload_path}), params)
12 end
13
14 defp process_callback(conn, pid, params) when is_pid(pid) do
15 send(pid, {Uploader, self(), conn, params})
16
17 receive do
18 {Uploader, conn} -> conn
19 end
20 end
21
22 defp process_callback(conn, _, _) do
23 render_error(conn, :bad_request, "bad request")
24 end
25 end