From 4a6d48b0fe991b68b555c75faca095725aff487b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 30 Mar 2017 16:08:23 +0200 Subject: [PATCH] Return mimetype with attachment. --- lib/pleroma/upload.ex | 6 +++++- lib/pleroma/web/twitter_api/twitter_api.ex | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 158656e92..d22421d37 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -8,7 +8,11 @@ def store(%Plug.Upload{} = file) 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 } diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index b6e7d5cc6..0624e73aa 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -99,6 +99,10 @@ def unfollow(%User{} = follower, followed_id) 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... """ @@ -106,9 +110,9 @@ def upload(%Plug.Upload{} = file) do #{object.id} #{object.id} #{object.id} - #{object.data["href"]} - #{object.data["href"]} - + #{href} + #{href} + """ end