1 defmodule Pleroma.Web.StreamerTest do
4 alias Pleroma.Web.Streamer
5 alias Pleroma.{List, User}
6 alias Pleroma.Web.CommonAPI
9 test "it sends to public" do
11 other_user = insert(:user)
15 assert_receive {:text, _}, 4_000
19 transport_pid: task.pid,
25 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "Test"})
28 "public" => [fake_socket]
31 Streamer.push_to_socket(topics, "public", activity)
36 test "it doesn't send to blocked users" do
38 blocked_user = insert(:user)
39 {:ok, user} = User.block(user, blocked_user)
43 refute_receive {:text, _}, 1_000
47 transport_pid: task.pid,
53 {:ok, activity} = CommonAPI.post(blocked_user, %{"status" => "Test"})
56 "public" => [fake_socket]
59 Streamer.push_to_socket(topics, "public", activity)
64 test "it doesn't send unwanted DMs to list" do
65 user_a = insert(:user)
66 user_b = insert(:user)
67 user_c = insert(:user)
69 {:ok, user_a} = User.follow(user_a, user_b)
71 {:ok, list} = List.create("Test", user_a)
72 {:ok, list} = List.follow(list, user_b)
76 refute_receive {:text, _}, 1_000
80 transport_pid: task.pid,
87 CommonAPI.post(user_b, %{
88 "status" => "@#{user_c.nickname} Test",
89 "visibility" => "direct"
93 "list:#{list.id}" => [fake_socket]
96 Streamer.handle_cast(%{action: :stream, topic: "list", item: activity}, topics)
101 test "it doesn't send unwanted private posts to list" do
102 user_a = insert(:user)
103 user_b = insert(:user)
105 {:ok, list} = List.create("Test", user_a)
106 {:ok, list} = List.follow(list, user_b)
110 refute_receive {:text, _}, 1_000
114 transport_pid: task.pid,
121 CommonAPI.post(user_b, %{
123 "visibility" => "private"
127 "list:#{list.id}" => [fake_socket]
130 Streamer.handle_cast(%{action: :stream, topic: "list", item: activity}, topics)
135 test "it send wanted private posts to list" do
136 user_a = insert(:user)
137 user_b = insert(:user)
139 {:ok, user_a} = User.follow(user_a, user_b)
141 {:ok, list} = List.create("Test", user_a)
142 {:ok, list} = List.follow(list, user_b)
146 assert_receive {:text, _}, 1_000
150 transport_pid: task.pid,
157 CommonAPI.post(user_b, %{
159 "visibility" => "private"
163 "list:#{list.id}" => [fake_socket]
166 Streamer.handle_cast(%{action: :stream, topic: "list", item: activity}, topics)