summaryrefslogtreecommitdiff
path: root/test/web/streamer_test.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <roman@Romans-MacBook-Pro-2.local>2019-06-05 02:45:21 +0300
committerRoman Chvanikov <roman@Romans-MacBook-Pro-2.local>2019-06-05 02:45:21 +0300
commitb1b1a270e8f17b76d08771ca1e4025b1d227da05 (patch)
tree41a5896012a3f55f3de31f7ec97dc397ba02cd62 /test/web/streamer_test.exs
parentf6036ce3b9649902ce1c2af819616ad25f0caef1 (diff)
parent5188add534a1532ef323a0fec3503f8e96dfe762 (diff)
downloadpleroma-b1b1a270e8f17b76d08771ca1e4025b1d227da05.tar.gz
pleroma-b1b1a270e8f17b76d08771ca1e4025b1d227da05.zip
Fix conflict
Diffstat (limited to 'test/web/streamer_test.exs')
-rw-r--r--test/web/streamer_test.exs78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/web/streamer_test.exs b/test/web/streamer_test.exs
index bfe18cb7f..c18b9f9fe 100644
--- a/test/web/streamer_test.exs
+++ b/test/web/streamer_test.exs
@@ -11,6 +11,16 @@ defmodule Pleroma.Web.StreamerTest do
alias Pleroma.Web.Streamer
import Pleroma.Factory
+ setup do
+ skip_thread_containment = Pleroma.Config.get([:instance, :skip_thread_containment])
+
+ on_exit(fn ->
+ Pleroma.Config.put([:instance, :skip_thread_containment], skip_thread_containment)
+ end)
+
+ :ok
+ end
+
test "it sends to public" do
user = insert(:user)
other_user = insert(:user)
@@ -68,6 +78,74 @@ defmodule Pleroma.Web.StreamerTest do
Task.await(task)
end
+ describe "thread_containment" do
+ test "it doesn't send to user if recipients invalid and thread containment is enabled" do
+ Pleroma.Config.put([:instance, :skip_thread_containment], false)
+ author = insert(:user)
+ user = insert(:user, following: [author.ap_id])
+
+ activity =
+ insert(:note_activity,
+ note:
+ insert(:note,
+ user: author,
+ data: %{"to" => ["TEST-FFF"]}
+ )
+ )
+
+ task = Task.async(fn -> refute_receive {:text, _}, 1_000 end)
+ fake_socket = %{transport_pid: task.pid, assigns: %{user: user}}
+ topics = %{"public" => [fake_socket]}
+ Streamer.push_to_socket(topics, "public", activity)
+
+ Task.await(task)
+ end
+
+ test "it sends message if recipients invalid and thread containment is disabled" do
+ Pleroma.Config.put([:instance, :skip_thread_containment], true)
+ author = insert(:user)
+ user = insert(:user, following: [author.ap_id])
+
+ activity =
+ insert(:note_activity,
+ note:
+ insert(:note,
+ user: author,
+ data: %{"to" => ["TEST-FFF"]}
+ )
+ )
+
+ task = Task.async(fn -> assert_receive {:text, _}, 1_000 end)
+ fake_socket = %{transport_pid: task.pid, assigns: %{user: user}}
+ topics = %{"public" => [fake_socket]}
+ Streamer.push_to_socket(topics, "public", activity)
+
+ Task.await(task)
+ end
+
+ test "it sends message if recipients invalid and thread containment is enabled but user's thread containment is disabled" do
+ Pleroma.Config.put([:instance, :skip_thread_containment], false)
+ author = insert(:user)
+ user = insert(:user, following: [author.ap_id], info: %{skip_thread_containment: true})
+
+ activity =
+ insert(:note_activity,
+ note:
+ insert(:note,
+ user: author,
+ data: %{"to" => ["TEST-FFF"]}
+ )
+ )
+
+ task = Task.async(fn -> assert_receive {:text, _}, 1_000 end)
+ fake_socket = %{transport_pid: task.pid, assigns: %{user: user}}
+ topics = %{"public" => [fake_socket]}
+ Streamer.push_to_socket(topics, "public", activity)
+
+ Task.await(task)
+ end
+ end
+
test "it doesn't send to blocked users" do
user = insert(:user)
blocked_user = insert(:user)