Add streaming tests
This commit is contained in:
parent
707b5ed39c
commit
c71e1e1e51
2 changed files with 34 additions and 1 deletions
|
@ -121,10 +121,13 @@ def get_followers(%Hashtag{id: hashtag_id}) do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_recipients_for_activity(%Pleroma.Activity{object: %{hashtags: tags}}) do
|
def get_recipients_for_activity(%Pleroma.Activity{object: %{hashtags: tags}})
|
||||||
|
when is_list(tags) do
|
||||||
tags
|
tags
|
||||||
|> Enum.map(&get_followers/1)
|
|> Enum.map(&get_followers/1)
|
||||||
|> List.flatten()
|
|> List.flatten()
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_recipients_for_activity(_activity), do: []
|
||||||
end
|
end
|
||||||
|
|
|
@ -410,6 +410,36 @@ test "it streams own edits in the 'user' stream", %{user: user, token: oauth_tok
|
||||||
assert_receive {:render_with_user, _, "status_update.json", ^create, ^stream}
|
assert_receive {:render_with_user, _, "status_update.json", ^create, ^stream}
|
||||||
refute Streamer.filtered_by_user?(user, edited)
|
refute Streamer.filtered_by_user?(user, edited)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it streams posts containing followed hashtags on the 'user' stream", %{
|
||||||
|
user: user,
|
||||||
|
token: oauth_token
|
||||||
|
} do
|
||||||
|
hashtag = insert(:hashtag, %{name: "tenshi"})
|
||||||
|
other_user = insert(:user)
|
||||||
|
{:ok, user} = User.follow_hashtag(user, hashtag)
|
||||||
|
|
||||||
|
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
||||||
|
{:ok, activity} = CommonAPI.post(other_user, %{status: "hey #tenshi"})
|
||||||
|
|
||||||
|
assert_receive {:render_with_user, _, "update.json", ^activity, _}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should not stream private posts containing followed hashtags on the 'user' stream", %{
|
||||||
|
user: user,
|
||||||
|
token: oauth_token
|
||||||
|
} do
|
||||||
|
hashtag = insert(:hashtag, %{name: "tenshi"})
|
||||||
|
other_user = insert(:user)
|
||||||
|
{:ok, user} = User.follow_hashtag(user, hashtag)
|
||||||
|
|
||||||
|
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(other_user, %{status: "hey #tenshi", visibility: "private"})
|
||||||
|
|
||||||
|
refute_receive {:render_with_user, _, "update.json", ^activity, _}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "public streams" do
|
describe "public streams" do
|
||||||
|
|
Loading…
Reference in a new issue