Merge branch '1335-user-api-id-fields-relations' into 'develop'
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api.ex
index cf396294409b77e2b610983d3c0a597b4840312c..ee253a342ead72af30d592fb067a976d22d0f86f 100644 (file)
@@ -24,19 +24,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
 
     with {:ok, follower, _followed, _} <- result do
       options = cast_params(params)
-
-      case reblogs_visibility(options[:reblogs], result) do
-        {:ok, follower} -> {:ok, follower}
-        _ -> {:ok, follower}
-      end
+      set_reblogs_visibility(options[:reblogs], result)
+      {:ok, follower}
     end
   end
 
-  defp reblogs_visibility(false, {:ok, follower, followed, _}) do
+  defp set_reblogs_visibility(false, {:ok, follower, followed, _}) do
     CommonAPI.hide_reblogs(follower, followed)
   end
 
-  defp reblogs_visibility(_, {:ok, follower, followed, _}) do
+  defp set_reblogs_visibility(_, {:ok, follower, followed, _}) do
     CommonAPI.show_reblogs(follower, followed)
   end
 
@@ -45,14 +42,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
     user
     |> User.get_followers_query()
     |> Pagination.fetch_paginated(params)
-    |> Map.get(:items)
   end
 
   def get_friends(user, params \\ %{}) do
     user
     |> User.get_friends_query()
     |> Pagination.fetch_paginated(params)
-    |> Map.get(:items)
   end
 
   def get_notifications(user, params \\ %{}) do
@@ -62,19 +57,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
     |> Notification.for_user_query(options)
     |> restrict(:exclude_types, options)
     |> Pagination.fetch_paginated(params)
-    |> Map.get(:items)
   end
 
   def get_scheduled_activities(user, params \\ %{}) do
     user
     |> ScheduledActivity.for_user_query()
     |> Pagination.fetch_paginated(params)
-    |> Map.get(:items)
   end
 
   defp cast_params(params) do
     param_types = %{
       exclude_types: {:array, :string},
+      exclude_visibilities: {:array, :string},
       reblogs: :boolean,
       with_muted: :boolean
     }