Used cached user resources in subscriptions
authorSadposter <hannah+pleroma@coffee-and-dreams.uk>
Mon, 8 Apr 2019 14:56:14 +0000 (15:56 +0100)
committerSadposter <hannah+pleroma@coffee-and-dreams.uk>
Mon, 8 Apr 2019 14:56:14 +0000 (15:56 +0100)
lib/pleroma/user.ex
lib/pleroma/web/common_api/utils.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index 15f606c5fc91443478e0fde6750a030509c066fd..8a02436049ef632fbfc2a660ff7e1bffbfdb6370 100644 (file)
@@ -926,7 +926,7 @@ defmodule Pleroma.User do
   def subscribe(subscriber, %{ap_id: ap_id}) do
     deny_follow_blocked = Pleroma.Config.get([:user, :deny_follow_blocked])
 
-    with %User{} = subscribed <- get_or_fetch_by_ap_id(ap_id) do
+    with %User{} = subscribed <- get_cached_by_ap_id(ap_id) do
       blocked = blocks?(subscribed, subscriber) and deny_follow_blocked
 
       if blocked do
@@ -944,7 +944,7 @@ defmodule Pleroma.User do
   end
 
   def unsubscribe(unsubscriber, %{ap_id: ap_id}) do
-    with %User{} = user <- get_or_fetch_by_ap_id(ap_id) do
+    with %User{} = user <- get_cached_by_ap_id(ap_id) do
       info_cng =
         user.info
         |> User.Info.remove_from_subscribers(unsubscriber.ap_id)
index a450a70c3bfa9b9d0fb71d79bb6c2e420dd18f3f..a830ea5d271e3b64039a702d204d26d5c1db0127 100644 (file)
@@ -341,7 +341,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
         %Activity{data: %{"actor" => actor, "type" => type}} = activity
       )
       when type == "Create" do
-    with %User{} = user <- User.get_by_ap_id(actor) do
+    with %User{} = user <- User.get_cached_by_ap_id(actor) do
       subscriber_ids =
         user
         |> User.subscribers()
index a7c9c4735a1c2ad9f77de5e730afd1dfd904cb84..d9c0cd55ee0fbb5bc8f820bd8d8e4364155a57e6 100644 (file)
@@ -864,7 +864,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   end
 
   def subscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) do
-    with %User{} = subscription_target <- User.get_by_id(id),
+    with %User{} = subscription_target <- User.get_cached_by_id(id),
          {:ok, subscription_target} = User.subscribe(user, subscription_target) do
       conn
       |> put_view(AccountView)
@@ -878,7 +878,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   end
 
   def unsubscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) do
-    with %User{} = subscription_target <- User.get_by_id(id),
+    with %User{} = subscription_target <- User.get_cached_by_id(id),
          {:ok, subscription_target} = User.unsubscribe(user, subscription_target) do
       conn
       |> put_view(AccountView)