aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-09-14 08:08:32 +0200
committerRoger Braun <roger@rogerbraun.net>2017-09-14 08:08:32 +0200
commit641c24cdd46f36205d91a2de7da8bbbfa7aac3ce (patch)
tree4566a0b4082e3a966bad469ff383272d5e88bcca /lib
parent3184939055fb8c1c9577a9d13e69c2c2f7e070c0 (diff)
downloadpleroma-641c24cdd46f36205d91a2de7da8bbbfa7aac3ce.tar.gz
Add media upload endpoint.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex9
-rw-r--r--lib/pleroma/web/router.ex2
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index f17cf40e6..b537bcf71 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -199,6 +199,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
render conn, AccountView, "relationships.json", %{user: user, targets: targets}
end
+ def upload(%{assigns: %{user: user}} = conn, %{"file" => file}) do
+ with {:ok, object} <- ActivityPub.upload(file) do
+ data = object.data
+ |> Map.put("id", object.id)
+
+ render conn, StatusView, "attachment.json", %{attachment: data}
+ end
+ end
+
def empty_array(conn, _) do
Logger.debug("Unimplemented, returning an empty array")
json(conn, [])
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 0bd8e40c4..93b31aba5 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -55,6 +55,8 @@ defmodule Pleroma.Web.Router do
post "/statuses/:id/unfavourite", MastodonAPIController, :unfav_status
get "/notifications", MastodonAPIController, :notifications
+
+ post "/media", MastodonAPIController, :upload
end
scope "/api/v1", Pleroma.Web.MastodonAPI do