Remerge of hashtag following #341
2 changed files with 34 additions and 1 deletions
|
@ -121,10 +121,13 @@ def get_followers(%Hashtag{id: hashtag_id}) do
|
|||
|> Repo.all()
|
||||
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
|
||||
|> Enum.map(&get_followers/1)
|
||||
|> List.flatten()
|
||||
|> Enum.uniq()
|
||||
end
|
||||
|
||||
def get_recipients_for_activity(_activity), do: []
|
||||
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}
|
||||
refute Streamer.filtered_by_user?(user, edited)
|
||||
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
|
||||
|
||||
describe "public streams" do
|
||||
|
|
Loading…
Reference in a new issue