summaryrefslogtreecommitdiff
path: root/test/web/common_api
diff options
context:
space:
mode:
authorIvan Tashkinov <ivant.business@gmail.com>2019-03-27 15:41:40 +0300
committerIvan Tashkinov <ivant.business@gmail.com>2019-03-27 15:41:40 +0300
commit20e0f3660541f19cf878b789aa9f5b9d5ce8cddb (patch)
tree08cb90d62e431beb7ee6a2261dc679b725aec1f1 /test/web/common_api
parent2a95014b9d7142aa2549e70f428293af78fae8eb (diff)
parent15aa94f40f73444d67da7cb71ec219b97ec5142e (diff)
downloadpleroma-20e0f3660541f19cf878b789aa9f5b9d5ce8cddb.tar.gz
pleroma-20e0f3660541f19cf878b789aa9f5b9d5ce8cddb.zip
Merge remote-tracking branch 'remotes/origin/develop' into twitter_oauth
Diffstat (limited to 'test/web/common_api')
-rw-r--r--test/web/common_api/common_api_test.exs18
-rw-r--r--test/web/common_api/common_api_utils_test.exs17
2 files changed, 35 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index f83f80b40..34aa5bf18 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -10,6 +10,24 @@ defmodule Pleroma.Web.CommonAPITest do
import Pleroma.Factory
+ test "with the safe_dm_mention option set, it does not mention people beyond the initial tags" do
+ har = insert(:user)
+ jafnhar = insert(:user)
+ tridi = insert(:user)
+ option = Pleroma.Config.get([:instance, :safe_dm_mentions])
+ Pleroma.Config.put([:instance, :safe_dm_mentions], true)
+
+ {:ok, activity} =
+ CommonAPI.post(har, %{
+ "status" => "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
+ "visibility" => "direct"
+ })
+
+ refute tridi.ap_id in activity.recipients
+ assert jafnhar.ap_id in activity.recipients
+ Pleroma.Config.put([:instance, :safe_dm_mentions], option)
+ end
+
test "it de-duplicates tags" do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu #2HU"})
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index 4c97b0d62..e04b9f9b5 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -4,6 +4,7 @@
defmodule Pleroma.Web.CommonAPI.UtilsTest do
alias Pleroma.Builders.UserBuilder
+ alias Pleroma.Object
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.Endpoint
use Pleroma.DataCase
@@ -136,4 +137,20 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
assert output == expected
end
end
+
+ describe "context_to_conversation_id" do
+ test "creates a mapping object" do
+ conversation_id = Utils.context_to_conversation_id("random context")
+ object = Object.get_by_ap_id("random context")
+
+ assert conversation_id == object.id
+ end
+
+ test "returns an existing mapping for an existing object" do
+ {:ok, object} = Object.context_mapping("random context") |> Repo.insert()
+ conversation_id = Utils.context_to_conversation_id("random context")
+
+ assert conversation_id == object.id
+ end
+ end
end