From 1ca080c8628d261cdb95145331aa36e631e90a3f Mon Sep 17 00:00:00 2001 From: eal Date: Fri, 14 Dec 2018 07:56:49 +0200 Subject: Prevent accidental double RTs or favorites --- test/web/common_api/common_api_test.exs | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 8fc65f4c0..0b5a235f8 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -2,6 +2,7 @@ defmodule Pleroma.Web.CommonAPI.Test do use Pleroma.DataCase alias Pleroma.Web.CommonAPI alias Pleroma.User + alias Pleroma.Activity import Pleroma.Factory @@ -53,4 +54,42 @@ defmodule Pleroma.Web.CommonAPI.Test do assert content == "

2hu

alert('xss')" end end + + describe "reactions" do + test "repeating a status" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) + + {:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user) + end + + test "favoriting a status" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) + + {:ok, %Activity{}, _} = CommonAPI.favorite(activity.id, user) + end + + test "retweeting a status twice returns an error" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) + {:ok, %Activity{}, _object} = CommonAPI.repeat(activity.id, user) + {:error, _} = CommonAPI.repeat(activity.id, user) + end + + test "favoriting a status twice returns an error" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) + {:ok, %Activity{}, _object} = CommonAPI.favorite(activity.id, user) + {:error, _} = CommonAPI.favorite(activity.id, user) + end + end end -- cgit v1.2.3 From 3c08d229db423052d0dd88b8a36fb39b0ae81ead Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 20:11:29 +0000 Subject: tests: add legal boilerplate --- test/web/common_api/common_api_test.exs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 0b5a235f8..c3674711a 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.CommonAPI.Test do use Pleroma.DataCase alias Pleroma.Web.CommonAPI -- cgit v1.2.3 From 380e9fba21123467b41629828f97d5f2c257a128 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Mon, 7 Jan 2019 20:45:33 +0700 Subject: add pinned posts --- test/web/common_api/common_api_test.exs | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index c3674711a..59beb3120 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -96,4 +96,40 @@ defmodule Pleroma.Web.CommonAPI.Test do {:error, _} = CommonAPI.favorite(activity.id, user) end end + + describe "pinned posts" do + test "pin post" do + Pleroma.Config.put([:instance, :max_pinned_posts], 1) + user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) + + assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) + end + + test "max pinned posts" do + Pleroma.Config.put([:instance, :max_pinned_posts], 1) + user = insert(:user) + + {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"}) + {:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"}) + + assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user) + + user = User.get_by_ap_id(user.ap_id) + + assert {:error, "You have already pinned the maximum number of toots"} = + CommonAPI.pin(activity_two.id, user) + end + + test "unpin post" do + Pleroma.Config.put([:instance, :max_pinned_posts], 1) + user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) + {:ok, activity} = CommonAPI.pin(activity.id, user) + + assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user) + end + end end -- cgit v1.2.3 From 63dbd875684b192e57d356a194c5d07ad98bd810 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 8 Jan 2019 15:25:50 +0700 Subject: rename `post` to `status` --- test/web/common_api/common_api_test.exs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 59beb3120..652b53099 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -97,9 +97,9 @@ defmodule Pleroma.Web.CommonAPI.Test do end end - describe "pinned posts" do - test "pin post" do - Pleroma.Config.put([:instance, :max_pinned_posts], 1) + describe "pinned statuses" do + test "pin status" do + Pleroma.Config.put([:instance, :max_pinned_statuses], 1) user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) @@ -107,8 +107,8 @@ defmodule Pleroma.Web.CommonAPI.Test do assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) end - test "max pinned posts" do - Pleroma.Config.put([:instance, :max_pinned_posts], 1) + test "max pinned statuses" do + Pleroma.Config.put([:instance, :max_pinned_statuses], 1) user = insert(:user) {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"}) @@ -122,8 +122,8 @@ defmodule Pleroma.Web.CommonAPI.Test do CommonAPI.pin(activity_two.id, user) end - test "unpin post" do - Pleroma.Config.put([:instance, :max_pinned_posts], 1) + test "unpin status" do + Pleroma.Config.put([:instance, :max_pinned_statuses], 1) user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) -- cgit v1.2.3 From db6f4496ebb5dbcb680104b2df80410b9dcb8407 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 8 Jan 2019 15:32:06 +0700 Subject: fix test --- test/web/common_api/common_api_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 652b53099..24e5e56f4 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -118,7 +118,7 @@ defmodule Pleroma.Web.CommonAPI.Test do user = User.get_by_ap_id(user.ap_id) - assert {:error, "You have already pinned the maximum number of toots"} = + assert {:error, "You have already pinned the maximum number of statuses"} = CommonAPI.pin(activity_two.id, user) end -- cgit v1.2.3 From 7b6c5f0a9d02785bee3e4c2585fea1f8983e61b0 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 8 Jan 2019 16:01:35 +0700 Subject: improve test readability --- test/web/common_api/common_api_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 24e5e56f4..7d5ceb398 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -116,7 +116,7 @@ defmodule Pleroma.Web.CommonAPI.Test do assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user) - user = User.get_by_ap_id(user.ap_id) + user = refresh_record(user) assert {:error, "You have already pinned the maximum number of statuses"} = CommonAPI.pin(activity_two.id, user) -- cgit v1.2.3 From 1b06e6fdf3d879422d6cb0fe57cfcef223b54196 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 9 Jan 2019 17:40:15 +0700 Subject: only non-reblogs, self-authored, public statuses can be pinned --- test/web/common_api/common_api_test.exs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 7d5ceb398..84b264439 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -107,6 +107,16 @@ defmodule Pleroma.Web.CommonAPI.Test do assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) end + test "only self-authored can be pinned" do + Pleroma.Config.put([:instance, :max_pinned_statuses], 1) + user_one = insert(:user) + user_two = insert(:user) + + {:ok, activity} = CommonAPI.post(user_one, %{"status" => "HI!!!"}) + + assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user_two) + end + test "max pinned statuses" do Pleroma.Config.put([:instance, :max_pinned_statuses], 1) user = insert(:user) -- cgit v1.2.3 From 6cbe63726d298ae85a75efa7591a54394469525e Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 9 Jan 2019 19:54:37 +0700 Subject: improve tests --- test/web/common_api/common_api_test.exs | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 84b264439..eb69ea4b2 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI.Test do @@ -98,30 +98,26 @@ defmodule Pleroma.Web.CommonAPI.Test do end describe "pinned statuses" do - test "pin status" do + setup do Pleroma.Config.put([:instance, :max_pinned_statuses], 1) - user = insert(:user) + user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) - assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) + [user: user, activity: activity] end - test "only self-authored can be pinned" do - Pleroma.Config.put([:instance, :max_pinned_statuses], 1) - user_one = insert(:user) - user_two = insert(:user) - - {:ok, activity} = CommonAPI.post(user_one, %{"status" => "HI!!!"}) - - assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user_two) + test "pin status", %{user: user, activity: activity} do + assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) end - test "max pinned statuses" do - Pleroma.Config.put([:instance, :max_pinned_statuses], 1) + test "only self-authored can be pinned", %{activity: activity} do user = insert(:user) - {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"}) + assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user) + end + + test "max pinned statuses", %{user: user, activity: activity_one} do {:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"}) assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user) @@ -132,11 +128,7 @@ defmodule Pleroma.Web.CommonAPI.Test do CommonAPI.pin(activity_two.id, user) end - test "unpin status" do - Pleroma.Config.put([:instance, :max_pinned_statuses], 1) - user = insert(:user) - - {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) + test "unpin status", %{user: user, activity: activity} do {:ok, activity} = CommonAPI.pin(activity.id, user) assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user) -- cgit v1.2.3 From b594a54d0caf0f91dd9188157cb34e01ee9ea794 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Fri, 11 Jan 2019 12:31:31 +0700 Subject: unpin when deleting a status --- test/web/common_api/common_api_test.exs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index eb69ea4b2..a3aff5897 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -109,6 +109,11 @@ defmodule Pleroma.Web.CommonAPI.Test do test "pin status", %{user: user, activity: activity} do assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) + + id = activity.id + user = refresh_record(user) + + assert %User{info: %{pinned_activities: [^id]}} = user end test "only self-authored can be pinned", %{activity: activity} do @@ -131,7 +136,25 @@ defmodule Pleroma.Web.CommonAPI.Test do test "unpin status", %{user: user, activity: activity} do {:ok, activity} = CommonAPI.pin(activity.id, user) + user = refresh_record(user) + assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user) + + user = refresh_record(user) + + assert %User{info: %{pinned_activities: []}} = user + end + + test "should unpin status when deleting a status", %{user: user, activity: activity} do + {:ok, activity} = CommonAPI.pin(activity.id, user) + + user = refresh_record(user) + + assert {:ok, _} = CommonAPI.delete(activity.id, user) + + user = refresh_record(user) + + assert %User{info: %{pinned_activities: []}} = user end end end -- cgit v1.2.3 From 728587fdaabbf8db8ee0d3626ab706044f0249f7 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Fri, 11 Jan 2019 12:47:44 +0700 Subject: typo --- test/web/common_api/common_api_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index a3aff5897..9ac805f24 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -145,7 +145,7 @@ defmodule Pleroma.Web.CommonAPI.Test do assert %User{info: %{pinned_activities: []}} = user end - test "should unpin status when deleting a status", %{user: user, activity: activity} do + test "should unpin when deleting a status", %{user: user, activity: activity} do {:ok, activity} = CommonAPI.pin(activity.id, user) user = refresh_record(user) -- cgit v1.2.3 From be0fb5dec47e5dc69aaef5f9c4f6910eba92b48a Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 20 Jan 2019 11:48:53 +0100 Subject: Add a test to ensure #39 is fixed. --- test/web/common_api/common_api_test.exs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 9ac805f24..a7d9e6161 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -17,6 +17,13 @@ defmodule Pleroma.Web.CommonAPI.Test do assert activity.data["object"]["tag"] == ["2hu"] end + test "it adds emoji in the object" do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => ":moominmamma:"}) + + assert activity.data["object"]["emoji"]["moominmamma"] + end + test "it adds emoji when updating profiles" do user = insert(:user, %{name: ":karjalanpiirakka:"}) -- cgit v1.2.3 From c01ef574c192488c2643a20b4064439757613449 Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Mon, 11 Feb 2019 11:59:51 +0100 Subject: Refactor as per Rin's suggestions, add endpoint tests --- test/web/common_api/common_api_test.exs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index a7d9e6161..d26b6e49c 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -164,4 +164,30 @@ defmodule Pleroma.Web.CommonAPI.Test do assert %User{info: %{pinned_activities: []}} = user end end + + describe "mute tests" do + setup do + user = insert(:user) + + activity = insert(:note_activity) + + [user: user, activity: activity] + end + + test "add mute", %{user: user, activity: activity} do + {:ok, _} = CommonAPI.add_mute(user, activity) + assert CommonAPI.thread_muted?(user, activity) + end + + test "remove mute", %{user: user, activity: activity} do + CommonAPI.add_mute(user, activity) + {:ok, _} = CommonAPI.remove_mute(user, activity) + refute CommonAPI.thread_muted?(user, activity) + end + + test "check that mutes can't be duplicate", %{user: user, activity: activity} do + CommonAPI.add_mute(user, activity) + {:error, _} = CommonAPI.add_mute(user, activity) + end + end end -- cgit v1.2.3 From 71c8c60ded8dce402dbe69545afebd55c63927e5 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 17 Feb 2019 17:47:24 +0100 Subject: More speedup, test fixes. --- test/web/common_api/common_api_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index d26b6e49c..870648fb5 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -2,7 +2,7 @@ # Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only -defmodule Pleroma.Web.CommonAPI.Test do +defmodule Pleroma.Web.CommonAPITest do use Pleroma.DataCase alias Pleroma.Web.CommonAPI alias Pleroma.User -- cgit v1.2.3 From bff9eb5ef7ad446376f68807d4e51db5f2de9515 Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 20 Feb 2019 16:51:25 +0000 Subject: Reports --- test/web/common_api/common_api_test.exs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 870648fb5..9ba320f59 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -190,4 +190,35 @@ defmodule Pleroma.Web.CommonAPITest do {:error, _} = CommonAPI.add_mute(user, activity) end end + + describe "reports" do + test "creates a report" do + reporter = insert(:user) + target_user = insert(:user) + + {:ok, activity} = CommonAPI.post(target_user, %{"status" => "foobar"}) + + reporter_ap_id = reporter.ap_id + target_ap_id = target_user.ap_id + activity_ap_id = activity.data["id"] + comment = "foobar" + + report_data = %{ + "account_id" => target_user.id, + "comment" => comment, + "status_ids" => [activity.id] + } + + assert {:ok, flag_activity} = CommonAPI.report(reporter, report_data) + + assert %Activity{ + actor: ^reporter_ap_id, + data: %{ + "type" => "Flag", + "content" => ^comment, + "object" => [^target_ap_id, ^activity_ap_id] + } + } = flag_activity + end + end end -- cgit v1.2.3 From a3a9cec4835738216800d2cebd295fb8dbf10f34 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 5 Mar 2019 03:52:23 +0100 Subject: [Credo] fix Credo.Check.Readability.AliasOrder --- test/web/common_api/common_api_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 9ba320f59..181813c76 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -4,9 +4,9 @@ defmodule Pleroma.Web.CommonAPITest do use Pleroma.DataCase - alias Pleroma.Web.CommonAPI - alias Pleroma.User alias Pleroma.Activity + alias Pleroma.User + alias Pleroma.Web.CommonAPI import Pleroma.Factory -- cgit v1.2.3 From da53c079db91ce5d7ba14809f5e99b10d3ae307a Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Fri, 15 Mar 2019 14:06:58 +0100 Subject: Refactor to store user ap_id, add tests --- test/web/common_api/common_api_test.exs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 181813c76..f83f80b40 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -221,4 +221,27 @@ defmodule Pleroma.Web.CommonAPITest do } = flag_activity end end + + describe "reblog muting" do + setup do + muter = insert(:user) + + muted = insert(:user) + + [muter: muter, muted: muted] + end + + test "add a reblog mute", %{muter: muter, muted: muted} do + {:ok, muter} = CommonAPI.hide_reblogs(muter, muted) + + assert Pleroma.User.showing_reblogs?(muter, muted) == false + end + + test "remove a reblog mute", %{muter: muter, muted: muted} do + {:ok, muter} = CommonAPI.hide_reblogs(muter, muted) + {:ok, muter} = CommonAPI.show_reblogs(muter, muted) + + assert Pleroma.User.showing_reblogs?(muter, muted) == true + end + end end -- cgit v1.2.3 From 8468f3f6d48693d2a27a257e5555aa71decff3df Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 20 Mar 2019 21:09:36 +0100 Subject: Add safe dm mode option. --- test/web/common_api/common_api_test.exs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') 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"}) -- cgit v1.2.3