Merge branch 'follow-request-count' into 'develop'

Follow request count

See merge request pleroma/pleroma!817
This commit is contained in:
kaniini 2019-02-18 04:01:26 +00:00
commit cd019a5927
9 changed files with 91 additions and 18 deletions

View file

@ -573,7 +573,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
{:ok, _activity} <-
ActivityPub.accept(%{
to: [follower.ap_id],
actor: followed.ap_id,
actor: followed,
object: follow_activity.data["id"],
type: "Accept"
}) do
@ -593,7 +593,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
{:ok, _activity} <-
ActivityPub.reject(%{
to: [follower.ap_id],
actor: followed.ap_id,
actor: followed,
object: follow_activity.data["id"],
type: "Reject"
}) do

View file

@ -113,10 +113,12 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
"fields" => fields,
# Pleroma extension
"pleroma" => %{
"confirmation_pending" => user_info.confirmation_pending,
"tags" => user.tags
}
"pleroma" =>
%{
"confirmation_pending" => user_info.confirmation_pending,
"tags" => user.tags
}
|> maybe_with_follow_request_count(user, for_user)
}
data =
@ -132,6 +134,14 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
end
end
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