From 8a47974217de4f714af11de7e5cb9b13e074d6ba Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 25 Feb 2018 18:08:41 +0100 Subject: [PATCH] Fix specs. --- lib/pleroma/web/common_api/common_api.ex | 2 +- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 6 +++--- test/support/builders/user_builder.ex | 4 +++- test/web/twitter_api/twitter_api_controller_test.exs | 1 - 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 5bd6e136f..d85a7cf5e 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -47,7 +47,7 @@ defmodule Pleroma.Web.CommonAPI do end def get_visibility(%{"visibility" => visibility}), do: visibility - def get_visibility(%{"in_reply_to_status_id" => status_id}) do + def get_visibility(%{"in_reply_to_status_id" => status_id}) when status_id do inReplyTo = get_replied_to_activity(status_id) Pleroma.Web.MastodonAPI.StatusView.get_visibility(inReplyTo.data["object"]) end diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 45b4d24c6..1f010a8ee 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -182,7 +182,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do |> Map.put("actor_id", ap_id) |> Map.put("whole_db", true) - activities = ActivityPub.fetch_activities([], params) + activities = ActivityPub.fetch_public_activities(params) |> Enum.reverse render conn, StatusView, "index.json", %{activities: activities, for: user, as: :activity} @@ -465,12 +465,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end def favourites(%{assigns: %{user: user}} = conn, _) do - params = conn + params = %{} |> Map.put("type", "Create") |> Map.put("favorited_by", user.ap_id) |> Map.put("blocking_user", user) - activities = ActivityPub.fetch_activities([], params) + activities = ActivityPub.fetch_public_activities(params) |> Enum.reverse conn diff --git a/test/support/builders/user_builder.ex b/test/support/builders/user_builder.ex index 710a1b87c..1e1e80ac9 100644 --- a/test/support/builders/user_builder.ex +++ b/test/support/builders/user_builder.ex @@ -14,6 +14,8 @@ defmodule Pleroma.Builders.UserBuilder do end def insert(data \\ %{}) do - Repo.insert(build(data)) + {:ok, user} = Repo.insert(build(data)) + User.invalidate_cache(user) + {:ok, user} end end diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index fbeec6605..d3040f0dc 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -218,7 +218,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "with user_id", %{conn: conn} do user = insert(:user) {:ok, activity} = ActivityBuilder.insert(%{"id" => 1}, %{user: user}) - |> IO.inspect conn = get(conn, "/api/statuses/user_timeline.json", %{"user_id" => user.id}) response = json_response(conn, 200) -- 2.45.2