Add Follow activity insertion

This commit is contained in:
dtluna 2017-04-04 03:30:07 +03:00
commit 8075badafe
4 changed files with 12 additions and 5 deletions

View file

@ -103,9 +103,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
def follow(%User{} = follower, followed_id) do
with %User{} = followed <- Repo.get(User, followed_id),
{ :ok, follower } <- User.follow(follower, followed)
{ :ok, follower } <- User.follow(follower, followed),
{ :ok, activity } <- ActivityPub.insert(%{
"type" => "Follow",
"actor" => follower.ap_id,
"object" => followed.ap_id
})
do
{ :ok, follower, followed }
{ :ok, follower, followed, activity }
end
end

View file

@ -44,7 +44,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
end
def follow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do
{ :ok, _user, follower } = TwitterAPI.follow(user, followed_id)
{ :ok, _user, follower, _activity } = TwitterAPI.follow(user, followed_id)
response = follower |> UserRepresenter.to_json(%{for: user})