From: eal Date: Tue, 14 Nov 2017 13:50:23 +0000 (+0200) Subject: Accept 1 as true. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=06c3ee3bac9abe5a369364743143618c473eb7a9;p=akkoma Accept 1 as true. --- diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 5b02fc2c6..9af0f553c 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -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 diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 1b8709941..a00a11f8b 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -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)