X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Ftwitter_api%2Ftwitter_api.ex;h=425ff4ad2b846d7b6d4768037c0646e3224d6c30;hb=3ff917b5dd72bc44f84a8f08cfc368faf28199f0;hp=0a942e880e538d1e92fd67f80a4b0ee1c1080828;hpb=0016589aea391fd6b8d41257b7f39f76b5b93775;p=akkoma diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 0a942e880..425ff4ad2 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -69,7 +69,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do end def fetch_friend_statuses(user, opts \\ %{}) do - ActivityPub.fetch_activities(user.following, opts) + ActivityPub.fetch_activities([user.ap_id | user.following], opts) |> activities_to_statuses(%{for: user}) end @@ -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)