implement tracking of follow requests
This commit is contained in:
parent
6041380774
commit
9c88933422
4 changed files with 41 additions and 2 deletions
|
|
@ -219,7 +219,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
@doc """
|
||||
Makes a follow activity data for the given follower and followed
|
||||
"""
|
||||
def make_follow_data(%User{ap_id: follower_id}, %User{ap_id: followed_id}, activity_id) do
|
||||
def make_follow_data(%User{ap_id: follower_id}, %User{ap_id: followed_id} = followed, activity_id) do
|
||||
data = %{
|
||||
"type" => "Follow",
|
||||
"actor" => follower_id,
|
||||
|
|
@ -229,6 +229,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
}
|
||||
|
||||
if activity_id, do: Map.put(data, "id", activity_id), else: data
|
||||
if User.locked?(followed), do: Map.put(data, "state", "pending"), else: data
|
||||
end
|
||||
|
||||
def fetch_latest_follow(%User{ap_id: follower_id}, %User{ap_id: followed_id}) do
|
||||
|
|
|
|||
|
|
@ -476,6 +476,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
end
|
||||
end
|
||||
|
||||
def follow_requests(%{assigns: %{user: followed}} = conn, _params) do
|
||||
with {:ok, follow_requests} <- User.get_follow_requests(followed) do
|
||||
render(conn, AccountView, "accounts.json", %{users: follow_requests, as: :user})
|
||||
end
|
||||
end
|
||||
|
||||
def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
|
||||
with %User{} = followed <- Repo.get(User, id),
|
||||
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
|
||||
|
|
|
|||
|
|
@ -97,11 +97,13 @@ defmodule Pleroma.Web.Router do
|
|||
post("/accounts/:id/mute", MastodonAPIController, :relationship_noop)
|
||||
post("/accounts/:id/unmute", MastodonAPIController, :relationship_noop)
|
||||
|
||||
get("/follow_requests", MastodonAPIController, :follow_requests)
|
||||
|
||||
post("/follows", MastodonAPIController, :follow)
|
||||
|
||||
get("/blocks", MastodonAPIController, :blocks)
|
||||
|
||||
get("/follow_requests", MastodonAPIController, :empty_array)
|
||||
get("/domain_blocks", MastodonAPIController, :empty_array)
|
||||
get("/mutes", MastodonAPIController, :empty_array)
|
||||
|
||||
get("/timelines/home", MastodonAPIController, :home_timeline)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue