Merge remote-tracking branch 'upstream/develop' into admin-create-users
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index 67f3638594479ebcfab994dcc0c2960c6653caa1..2110027c3da313d238f06894c21fa38a54071f78 100644 (file)
@@ -11,6 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   alias Pleroma.Conversation.Participation
   alias Pleroma.Filter
   alias Pleroma.Formatter
+  alias Pleroma.HTTP
   alias Pleroma.Notification
   alias Pleroma.Object
   alias Pleroma.Object.Fetcher
@@ -55,7 +56,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     when action in [:account_register]
   )
 
-  @httpoison Application.get_env(:pleroma, :httpoison)
   @local_mastodon_name "Mastodon-Local"
 
   action_fallback(:errors)
@@ -729,13 +729,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         |> json(rendered)
       else
         conn
+        |> put_resp_content_type("application/json")
         |> send_resp(415, Jason.encode!(%{"error" => "mascots can only be images"}))
       end
     end
   end
 
   def get_mascot(%{assigns: %{user: user}} = conn, _params) do
-    %{info: %{mascot: mascot}} = user
+    mascot = User.get_mascot(user)
 
     conn
     |> json(mascot)
@@ -1083,7 +1084,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       from([a, o] in Activity.with_preloaded_object(Activity),
         where: fragment("?->>'type' = 'Create'", a.data),
         where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
-        limit: 20
+        limit: 40
       )
 
     q =
@@ -1363,7 +1364,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
             display_sensitive_media: false,
             reduce_motion: false,
             max_toot_chars: limit,
-            mascot: Map.get(user.info.mascot, "url", "/images/pleroma-fox-tan-smol.png")
+            mascot: User.get_mascot(user)["url"]
           },
           rights: %{
             delete_others_notice: present?(user.info.is_moderator),
@@ -1690,7 +1691,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         |> String.replace("{{user}}", user)
 
       with {:ok, %{status: 200, body: body}} <-
-             @httpoison.get(
+             HTTP.get(
                url,
                [],
                adapter: [