Accept 1 as true.
authoreal <eal@waifu.club>
Tue, 14 Nov 2017 13:50:23 +0000 (15:50 +0200)
committereal <eal@waifu.club>
Tue, 14 Nov 2017 13:54:50 +0000 (15:54 +0200)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 5b02fc2c6b71e952bd085b8e90342656eed4f0e5..9af0f553c47e4d9be266401bde835bff1264fd97 100644 (file)
@@ -159,7 +159,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   end
   defp restrict_favorited_by(query, _), do: query
 
-  defp restrict_media(query, %{"only_media" => true}) do
+  defp restrict_media(query, %{"only_media" => val}) when val == "true" or val == "1" do
     from activity in query,
       where: fragment("not (? #> '{\"object\",\"attachment\"}' = ?)", activity.data, ^[])
   end
index 1b87099415734c5c787a90e28164a0d228b0ee2b..a00a11f8b46aec3929c58fcfc377ef3f499e521c 100644 (file)
@@ -261,7 +261,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       {:ok, image_post} = TwitterAPI.create_status(user, %{"status" => "cofe", "media_ids" => [media["media_id"]]})
 
       conn = conn
-      |> get("/api/v1/accounts/#{user.id}/statuses", %{"only_media" => true})
+      |> get("/api/v1/accounts/#{user.id}/statuses", %{"only_media" => "true"})
+
+      assert [%{"id" => id}] = json_response(conn, 200)
+      assert id == to_string(image_post.id)
+
+      conn = build_conn()
+      |> get("/api/v1/accounts/#{user.id}/statuses", %{"only_media" => "1"})
 
       assert [%{"id" => id}] = json_response(conn, 200)
       assert id == to_string(image_post.id)