aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex26
-rw-r--r--lib/pleroma/user/info.ex1
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex12
-rw-r--r--lib/pleroma/web/twitter_api/views/user_view.ex9
4 files changed, 4 insertions, 44 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index d58274508..0d2b838db 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -621,32 +621,6 @@ defmodule Pleroma.User do
)
end
- def update_follow_request_count(%User{} = user) do
- subquery =
- user
- |> User.get_follow_requests_query()
- |> select([a], %{count: count(a.id)})
-
- User
- |> where(id: ^user.id)
- |> join(:inner, [u], s in subquery(subquery))
- |> update([u, s],
- set: [
- info:
- fragment(
- "jsonb_set(?, '{follow_request_count}', ?::varchar::jsonb, true)",
- u.info,
- s.count
- )
- ]
- )
- |> Repo.update_all([], returning: true)
- |> case do
- {1, [user]} -> {:ok, user}
- _ -> {:error, user}
- end
- end
-
def get_follow_requests(%User{} = user) do
q = get_follow_requests_query(user)
reqs = Repo.all(q)
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index 00a0f6df3..818b64645 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -12,7 +12,6 @@ defmodule Pleroma.User.Info do
field(:source_data, :map, default: %{})
field(:note_count, :integer, default: 0)
field(:follower_count, :integer, default: 0)
- field(:follow_request_count, :integer, default: 0)
field(:locked, :boolean, default: false)
field(:confirmation_pending, :boolean, default: false)
field(:confirmation_token, :string, default: nil)
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index b81198629..7282d4239 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -175,8 +175,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
with data <- %{"to" => to, "type" => "Accept", "actor" => actor.ap_id, "object" => object},
{:ok, activity} <- insert(data, local),
- :ok <- maybe_federate(activity),
- _ <- User.update_follow_request_count(actor) do
+ :ok <- maybe_federate(activity) do
{:ok, activity}
end
end
@@ -187,8 +186,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
with data <- %{"to" => to, "type" => "Reject", "actor" => actor.ap_id, "object" => object},
{:ok, activity} <- insert(data, local),
- :ok <- maybe_federate(activity),
- _ <- User.update_follow_request_count(actor) do
+ :ok <- maybe_federate(activity) do
{:ok, activity}
end
end
@@ -286,8 +284,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
def follow(follower, followed, activity_id \\ nil, local \\ true) do
with data <- make_follow_data(follower, followed, activity_id),
{:ok, activity} <- insert(data, local),
- :ok <- maybe_federate(activity),
- _ <- User.update_follow_request_count(followed) do
+ :ok <- maybe_federate(activity) do
{:ok, activity}
end
end
@@ -297,8 +294,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
{:ok, follow_activity} <- update_follow_state(follow_activity, "cancelled"),
unfollow_data <- make_unfollow_data(follower, followed, follow_activity, activity_id),
{:ok, activity} <- insert(unfollow_data, local),
- :ok <- maybe_federate(activity),
- _ <- User.update_follow_request_count(followed) do
+ :ok <- maybe_federate(activity) do
{:ok, activity}
end
end
diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex
index 22f33e0b5..e72ce977c 100644
--- a/lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/lib/pleroma/web/twitter_api/views/user_view.ex
@@ -133,7 +133,6 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
"tags" => user.tags
}
|> maybe_with_activation_status(user, for_user)
- |> maybe_with_follow_request_count(user, for_user)
}
data =
@@ -155,14 +154,6 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
defp maybe_with_activation_status(data, _, _), do: data
- defp maybe_with_follow_request_count(data, %User{id: id, info: %{locked: true}} = user, %User{
- id: id
- }) do
- Map.put(data, "follow_request_count", user.info.follow_request_count)
- end
-
- defp maybe_with_follow_request_count(data, _, _), do: data
-
defp maybe_with_role(data, %User{id: id} = user, %User{id: id}) do
Map.merge(data, %{"role" => role(user), "show_role" => user.info.show_role})
end