From 260f09dd6cc3d1d0b616496bfbc4a758ef84fa39 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 17 Sep 2017 14:20:54 +0200 Subject: [PATCH] MastoAPI: Return reblogs, too. --- lib/pleroma/web/activity_pub/activity_pub.ex | 5 ++++- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 0cfd22d7b..31aa2c4f1 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -141,9 +141,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end defp restrict_actor(query, _), do: query + defp restrict_type(query, %{"type" => type}) when is_binary(type) do + restrict_type(query, %{"type" => [type]}) + end defp restrict_type(query, %{"type" => type}) do from activity in query, - where: fragment("?->>'type' = ?", activity.data, ^type) + where: fragment("?->>'type' = ANY(?)", activity.data, ^type) end defp restrict_type(query, _), do: query diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index dd1044024..a01a199fb 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -77,7 +77,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end def home_timeline(%{assigns: %{user: user}} = conn, params) do - activities = ActivityPub.fetch_activities([user.ap_id | user.following], Map.put(params, "type", "Create")) + params = params + |> Map.put("type", ["Create", "Announce"]) + + activities = ActivityPub.fetch_activities([user.ap_id | user.following], params) |> Enum.reverse conn @@ -87,7 +90,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def public_timeline(%{assigns: %{user: user}} = conn, params) do params = params - |> Map.put("type", "Create") + |> Map.put("type", ["Create", "Announce"]) |> Map.put("local_only", !!params["local"]) activities = ActivityPub.fetch_public_activities(params) @@ -102,7 +105,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def user_statuses(%{assigns: %{user: user}} = conn, params) do with %User{ap_id: ap_id} <- Repo.get(User, params["id"]) do params = params - |> Map.put("type", "Create") + |> Map.put("type", ["Create", "Announce"]) |> Map.put("actor_id", ap_id) activities = ActivityPub.fetch_activities([], params) -- 2.45.2