Used cached user resources in subscriptions
This commit is contained in:
parent
87a01f9ee0
commit
589629cf3e
@ -926,7 +926,7 @@ defmodule Pleroma.User do
|
|||||||
def subscribe(subscriber, %{ap_id: ap_id}) do
|
def subscribe(subscriber, %{ap_id: ap_id}) do
|
||||||
deny_follow_blocked = Pleroma.Config.get([:user, :deny_follow_blocked])
|
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
|
blocked = blocks?(subscribed, subscriber) and deny_follow_blocked
|
||||||
|
|
||||||
if blocked do
|
if blocked do
|
||||||
@ -944,7 +944,7 @@ defmodule Pleroma.User do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unsubscribe(unsubscriber, %{ap_id: ap_id}) do
|
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 =
|
info_cng =
|
||||||
user.info
|
user.info
|
||||||
|> User.Info.remove_from_subscribers(unsubscriber.ap_id)
|
|> User.Info.remove_from_subscribers(unsubscriber.ap_id)
|
||||||
|
@ -341,7 +341,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||||||
%Activity{data: %{"actor" => actor, "type" => type}} = activity
|
%Activity{data: %{"actor" => actor, "type" => type}} = activity
|
||||||
)
|
)
|
||||||
when type == "Create" do
|
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 =
|
subscriber_ids =
|
||||||
user
|
user
|
||||||
|> User.subscribers()
|
|> User.subscribers()
|
||||||
|
@ -864,7 +864,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def subscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
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
|
{:ok, subscription_target} = User.subscribe(user, subscription_target) do
|
||||||
conn
|
conn
|
||||||
|> put_view(AccountView)
|
|> put_view(AccountView)
|
||||||
@ -878,7 +878,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unsubscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
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
|
{:ok, subscription_target} = User.unsubscribe(user, subscription_target) do
|
||||||
conn
|
conn
|
||||||
|> put_view(AccountView)
|
|> put_view(AccountView)
|
||||||
|
Loading…
Reference in New Issue
Block a user