Return mimetype with attachment.
authorRoger Braun <roger@rogerbraun.net>
Thu, 30 Mar 2017 14:08:23 +0000 (16:08 +0200)
committerRoger Braun <roger@rogerbraun.net>
Thu, 30 Mar 2017 14:08:23 +0000 (16:08 +0200)
lib/pleroma/upload.ex
lib/pleroma/web/twitter_api/twitter_api.ex

index 158656e92ea117674aadabe89fd149aeeb9a02e0..d22421d37049d8d4892037b83c89b90718a995a5 100644 (file)
@@ -8,7 +8,11 @@ defmodule Pleroma.Upload do
 
     %{
       "type" => "Image",
-      "href" => url_for(Path.join(uuid, file.filename)),
+      "url" => [%{
+        "type" => "Link",
+        "mediaType" => file.content_type,
+        "href" => url_for(Path.join(uuid, file.filename))
+      }],
       "name" => file.filename,
       "uuid" => uuid
     }
index b6e7d5cc6ae407cd039d50c0843f4015832af97b..0624e73aa0cd19bf860bda2268cb30eb9a6467ba 100644 (file)
@@ -99,6 +99,10 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
   def upload(%Plug.Upload{} = file) do
     {:ok, object} = ActivityPub.upload(file)
 
+    url = List.first(object.data["url"])
+    href = url["href"]
+    type = url["mediaType"]
+
     # Fake this as good as possible...
     """
     <?xml version="1.0" encoding="UTF-8"?>
@@ -106,9 +110,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
       <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>
+      <media_url>#{href}</media_url>
+      <mediaurl>#{href}</mediaurl>
+      <atom:link rel="enclosure" href="#{href}" type="#{type}"></atom:link>
     </rsp>
     """
   end