From 589629cf3e1bee9a4f6e92b8456d8614eff73c89 Mon Sep 17 00:00:00 2001 From: Sadposter Date: Mon, 8 Apr 2019 15:56:14 +0100 Subject: [PATCH] Used cached user resources in subscriptions --- lib/pleroma/user.ex | 4 ++-- lib/pleroma/web/common_api/utils.ex | 2 +- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 15f606c5f..8a0243604 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -926,7 +926,7 @@ def unmute(muter, %{ap_id: ap_id}) 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 @@ def subscribe(subscriber, %{ap_id: ap_id}) 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) diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index a450a70c3..a830ea5d2 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -341,7 +341,7 @@ def maybe_notify_subscribers( %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() diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index a7c9c4735..d9c0cd55e 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -864,7 +864,7 @@ def unblock_domain(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) d 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 @@ def subscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) 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)