Add following using screen_name parameter
This commit is contained in:
parent
b5e94bf930
commit
896e40cd2b
3 changed files with 32 additions and 5 deletions
|
|
@ -101,7 +101,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
end
|
||||
end
|
||||
|
||||
def follow(%User{} = follower, followed_id) do
|
||||
def follow(%User{} = follower, %{ "user_id" => followed_id }) do
|
||||
with %User{} = followed <- Repo.get(User, followed_id),
|
||||
{ :ok, follower } <- User.follow(follower, followed),
|
||||
{ :ok, activity } <- ActivityPub.insert(%{
|
||||
|
|
@ -115,6 +115,20 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
end
|
||||
end
|
||||
|
||||
def follow(%User{} = follower, %{ "screen_name" => followed_name }) do
|
||||
with %User{} = followed <- Repo.get_by(User, nickname: followed_name),
|
||||
{ :ok, follower } <- User.follow(follower, followed),
|
||||
{ :ok, activity } <- ActivityPub.insert(%{
|
||||
"type" => "Follow",
|
||||
"actor" => follower.ap_id,
|
||||
"object" => followed.ap_id,
|
||||
"published" => make_date()
|
||||
})
|
||||
do
|
||||
{ :ok, follower, followed, activity }
|
||||
end
|
||||
end
|
||||
|
||||
def unfollow(%User{} = follower, followed_id) do
|
||||
with %User{} = followed <- Repo.get(User, followed_id),
|
||||
{ :ok, follower } <- User.unfollow(follower, followed)
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
|> json_reply(200, json)
|
||||
end
|
||||
|
||||
def follow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do
|
||||
{ :ok, _user, follower, _activity } = TwitterAPI.follow(user, followed_id)
|
||||
def follow(%{assigns: %{user: user}} = conn, params) do
|
||||
{ :ok, _user, follower, _activity } = TwitterAPI.follow(user, params)
|
||||
|
||||
response = follower |> UserRepresenter.to_json(%{for: user})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue