PleromaAPIController: Fixes and refactoring.
authorlain <lain@soykaf.club>
Mon, 30 Sep 2019 13:13:25 +0000 (15:13 +0200)
committerlain <lain@soykaf.club>
Mon, 30 Sep 2019 13:13:25 +0000 (15:13 +0200)
lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex
test/web/activity_pub/transmogrifier_test.exs

index 474b8d079bb5edabde423f0c38cc8492cc1e779b..39d371ff706f4313b11f2e5abccefb51fc52e820 100644 (file)
@@ -23,17 +23,12 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do
     with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id),
          %Object{data: %{"reactions" => emoji_reactions}} <- Object.normalize(activity) do
       reactions =
-        Enum.reduce(emoji_reactions, %{}, fn {emoji, users}, res ->
-          users =
-            users
-            |> Enum.map(&User.get_cached_by_ap_id/1)
-
-          res
-          |> Map.put(
-            emoji,
-            AccountView.render("accounts.json", %{users: users, for: user, as: :user})
-          )
+        emoji_reactions
+        |> Enum.map(fn {emoji, users} ->
+          users = Enum.map(users, &User.get_cached_by_ap_id/1)
+          {emoji, AccountView.render("accounts.json", %{users: users, for: user, as: :user})}
         end)
+        |> Enum.into(%{})
 
       conn
       |> json(reactions)
@@ -49,7 +44,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do
          activity = Activity.get_by_id(activity_id) do
       conn
       |> put_view(StatusView)
-      |> render("status.json", %{activity: activity, for: user, as: :activity})
+      |> render("show.json", %{activity: activity, for: user, as: :activity})
     end
   end
 
index ba2a4329673dff1450cbb01481d359c69146e1d6..f1ceb20d2d9c0e7d56b768a8d2a979b053144a8e 100644 (file)
@@ -1263,7 +1263,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
       {:ok, activity} = CommonAPI.listen(user, %{"title" => "lain radio episode 1"})
 
-      {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+      {:ok, _modified} = Transmogrifier.prepare_outgoing(activity.data)
     end
   end