From 9ade1242c20acae5d27785deb833b453628b12ee Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 27 Feb 2019 16:52:03 +0100 Subject: Add user muted status info to twitterapi. --- test/web/twitter_api/views/activity_view_test.exs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs index 4f854ecaa..0a5384f34 100644 --- a/test/web/twitter_api/views/activity_view_test.exs +++ b/test/web/twitter_api/views/activity_view_test.exs @@ -56,6 +56,22 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do assert result["user"]["id"] == user.id end + test "tells if the message is muted for some reason" do + user = insert(:user) + other_user = insert(:user) + + {:ok, user} = User.mute(user, other_user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"}) + status = ActivityView.render("activity.json", %{activity: activity}) + + assert status["muted"] == false + + status = ActivityView.render("activity.json", %{activity: activity, for: user}) + + assert status["muted"] == true + end + test "a create activity with a html status" do text = """ #Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg @@ -149,7 +165,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do "uri" => activity.data["object"]["id"], "user" => UserView.render("show.json", %{user: user}), "visibility" => "direct", - "card" => nil + "card" => nil, + "muted" => false } assert result == expected -- cgit v1.2.3 From bbbdbec4fd8f14aa039d7f4a42215544cd6e4932 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 27 Feb 2019 17:24:51 +0100 Subject: Remove parts of the old activity view. Not used anymore. --- .../representers/activity_representer_test.exs | 43 +--------------------- 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 365c7f659..0e554623c 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -13,36 +13,6 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do alias Pleroma.Web.TwitterAPI.UserView import Pleroma.Factory - test "an announce activity" do - user = insert(:user) - note_activity = insert(:note_activity) - activity_actor = Repo.get_by(User, ap_id: note_activity.data["actor"]) - object = Object.get_by_ap_id(note_activity.data["object"]["id"]) - - {:ok, announce_activity, _object} = ActivityPub.announce(user, object) - note_activity = Activity.get_by_ap_id(note_activity.data["id"]) - - status = - ActivityRepresenter.to_map(announce_activity, %{ - users: [user, activity_actor], - announced_activity: note_activity, - for: user - }) - - assert status["id"] == announce_activity.id - assert status["user"] == UserView.render("show.json", %{user: user, for: user}) - - retweeted_status = - ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user}) - - assert retweeted_status["repeated"] == true - assert retweeted_status["id"] == note_activity.id - assert status["statusnet_conversation_id"] == retweeted_status["statusnet_conversation_id"] - - assert status["retweeted_status"] == retweeted_status - assert status["activity_type"] == "repeat" - end - test "a like activity" do user = insert(:user) note_activity = insert(:note_activity) @@ -168,6 +138,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "uri" => activity.data["object"]["id"], "visibility" => "direct", "card" => nil, + "muted" => false, "summary" => "2hu :2hu:", "summary_html" => "2hu \"2hu\"" @@ -180,18 +151,6 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do }) == expected_status end - test "an undo for a follow" do - follower = insert(:user) - followed = insert(:user) - - {:ok, _follow} = ActivityPub.follow(follower, followed) - {:ok, unfollow} = ActivityPub.unfollow(follower, followed) - - map = ActivityRepresenter.to_map(unfollow, %{user: follower}) - assert map["is_post_verb"] == false - assert map["activity_type"] == "undo" - end - test "a delete activity" do object = insert(:note) user = User.get_by_ap_id(object.data["actor"]) -- cgit v1.2.3 From 6b11011039dca5090c3a7b7b2a01f32b666be380 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 28 Feb 2019 08:31:33 +0300 Subject: Added deactivated to the user view --- test/web/twitter_api/views/user_view_test.exs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 95e52ca46..114f24a1c 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -239,6 +239,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do assert represented["role"] == nil end + test "A regular user for the admin", %{user: user} do + admin = insert(:user, %{info: %{is_admin: true}}) + represented = UserView.render("show.json", %{user: user, for: admin}) + + assert represented["pleroma"]["deactivated"] == false + end + test "A blocked user for the blocker" do user = insert(:user) blocker = insert(:user) -- cgit v1.2.3 From 1341ee650ecde656f385454264f43b21051e86f2 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 1 Mar 2019 09:37:29 +0300 Subject: [#675] Do not show DMs in mentions timeline --- test/web/twitter_api/twitter_api_controller_test.exs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 05a832967..ed5683779 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -427,7 +427,10 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "with credentials", %{conn: conn, user: current_user} do {:ok, activity} = - ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: current_user}) + ActivityBuilder.insert( + %{"to" => [current_user.ap_id, "https://www.w3.org/ns/activitystreams#Public"]}, + %{user: current_user} + ) conn = conn @@ -445,6 +448,20 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do mentioned: [current_user] }) end + + test "does not show DMs in mentions timeline", %{conn: conn, user: current_user} do + {:ok, _activity} = + ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: current_user}) + + conn = + conn + |> with_credentials(current_user.nickname, "test") + |> get("/api/statuses/mentions.json") + + response = json_response(conn, 200) + + assert length(response) == 0 + end end describe "GET /api/qvitter/statuses/notifications.json" do -- cgit v1.2.3 From 9c6abec4d8b2487edeb124aa197a5dd6d771e345 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 1 Mar 2019 15:48:04 +0300 Subject: use commonapi.post instead of activitybulder --- test/web/twitter_api/twitter_api_controller_test.exs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index ed5683779..7125d85ab 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -427,10 +427,10 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "with credentials", %{conn: conn, user: current_user} do {:ok, activity} = - ActivityBuilder.insert( - %{"to" => [current_user.ap_id, "https://www.w3.org/ns/activitystreams#Public"]}, - %{user: current_user} - ) + CommonAPI.post(current_user, %{ + "status" => "why is tenshi eating a corndog so cute?", + "visibility" => "public" + }) conn = conn @@ -451,7 +451,10 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "does not show DMs in mentions timeline", %{conn: conn, user: current_user} do {:ok, _activity} = - ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: current_user}) + CommonAPI.post(current_user, %{ + "status" => "Have you guys ever seen how cute tenshi eating a corndog is?", + "visibility" => "direct" + }) conn = conn -- cgit v1.2.3 From d5418e9ff78785c48bc94fbc8cb146ffe90c1fc5 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sun, 3 Mar 2019 18:39:37 +0300 Subject: Remove follow_request_count as it's not needed for FE anymore. MastoFE uses `GET /api/v1/follow_requests` and PleromaFE uses `GET /api/pleroma/friend_requests` which they query on the initial page load. --- test/web/twitter_api/twitter_api_controller_test.exs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 7125d85ab..d18b65876 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -690,7 +690,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do followed = Repo.get(User, followed.id) refute User.ap_followers(followed) in current_user.following - assert followed.info.follow_request_count == 1 assert json_response(conn, 200) == UserView.render("show.json", %{user: followed, for: current_user}) @@ -1757,7 +1756,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do other_user = Repo.get(User, other_user.id) assert User.following?(other_user, user) == false - assert user.info.follow_request_count == 1 conn = build_conn() @@ -1769,7 +1767,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do assert relationship = json_response(conn, 200) assert other_user.id == relationship["id"] assert relationship["follows_you"] == true - assert user.info.follow_request_count == 0 end end @@ -1784,7 +1781,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do other_user = Repo.get(User, other_user.id) assert User.following?(other_user, user) == false - assert user.info.follow_request_count == 1 conn = build_conn() @@ -1796,7 +1792,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do assert relationship = json_response(conn, 200) assert other_user.id == relationship["id"] assert relationship["follows_you"] == false - assert user.info.follow_request_count == 0 end end -- cgit v1.2.3