2019-07-09 23:13:23 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-01 04:11:47 -07:00
|
|
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
2019-07-09 23:13:23 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-01-21 14:44:14 -07:00
|
|
|
defmodule Pleroma.Web.UploaderController do
|
|
|
|
use Pleroma.Web, :controller
|
|
|
|
|
|
|
|
alias Pleroma.Uploaders.Uploader
|
|
|
|
|
2019-02-03 10:44:18 -07:00
|
|
|
def callback(conn, %{"upload_path" => upload_path} = params) do
|
2019-01-21 14:44:14 -07:00
|
|
|
process_callback(conn, :global.whereis_name({Uploader, upload_path}), params)
|
|
|
|
end
|
|
|
|
|
|
|
|
defp process_callback(conn, pid, params) when is_pid(pid) do
|
|
|
|
send(pid, {Uploader, self(), conn, params})
|
|
|
|
|
|
|
|
receive do
|
|
|
|
{Uploader, conn} -> conn
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
defp process_callback(conn, _, _) do
|
2019-07-10 03:25:58 -06:00
|
|
|
render_error(conn, :bad_request, "bad request")
|
2019-01-21 14:44:14 -07:00
|
|
|
end
|
|
|
|
end
|