Basic file uploading via TwAPI.
This commit is contained in:
parent
08fdbd6f3a
commit
e7dc39e40c
10 changed files with 57 additions and 6 deletions
|
|
@ -96,6 +96,23 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
end
|
||||
end
|
||||
|
||||
def upload(%Plug.Upload{} = file) do
|
||||
{:ok, object} = ActivityPub.upload(file)
|
||||
|
||||
# Fake this as good as possible...
|
||||
"""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rsp stat="ok" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<mediaid>#{object.id}</mediaid>
|
||||
<media_id>#{object.id}</media_id>
|
||||
<media_id_string>#{object.id}</media_id_string>
|
||||
<media_url>#{object.data["href"]}</media_url>
|
||||
<mediaurl>#{object.data["href"]}</mediaurl>
|
||||
<atom:link rel="enclosure" href="#{object.data["href"]}" type="image"></atom:link>
|
||||
</rsp>
|
||||
"""
|
||||
end
|
||||
|
||||
defp add_conversation_id(activity) do
|
||||
if is_integer(activity.data["statusnetConversationId"]) do
|
||||
{:ok, activity}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,12 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
|> json_reply(200, response)
|
||||
end
|
||||
|
||||
def upload(conn, %{"media" => media}) do
|
||||
response = TwitterAPI.upload(media)
|
||||
conn
|
||||
|> put_resp_content_type("application/atom+xml")
|
||||
|> send_resp(200, response)
|
||||
end
|
||||
|
||||
defp json_reply(conn, status, json) do
|
||||
conn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue