Return directly addressed activities in friends timeline.

This commit is contained in:
Roger Braun 2017-04-12 16:45:23 +02:00
parent 15655d992e
commit 8eea09889b
2 changed files with 4 additions and 2 deletions

View file

@ -69,7 +69,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
end end
def fetch_friend_statuses(user, opts \\ %{}) do 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}) |> activities_to_statuses(%{for: user})
end end

View file

@ -82,14 +82,16 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
test "fetch friends' statuses" do test "fetch friends' statuses" do
ActivityBuilder.public_and_non_public ActivityBuilder.public_and_non_public
{:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]}) {:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]})
{:ok, direct_activity} = ActivityBuilder.insert(%{"to" => ["some other id"]})
{:ok, user} = UserBuilder.insert(%{ap_id: "some other id", following: ["someguy/followers"]}) {:ok, user} = UserBuilder.insert(%{ap_id: "some other id", following: ["someguy/followers"]})
statuses = TwitterAPI.fetch_friend_statuses(user) statuses = TwitterAPI.fetch_friend_statuses(user)
activity_user = Repo.get_by(User, ap_id: activity.data["actor"]) activity_user = Repo.get_by(User, ap_id: activity.data["actor"])
assert length(statuses) == 1 assert length(statuses) == 2
assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: activity_user}) assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: activity_user})
end end