|> get("/api/v1/notifications")
expected_response =
- "hi <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{user.id}\" href=\"#{
- user.ap_id
- }\" rel=\"ugc\">@<span>#{user.nickname}</span></a></span>"
+ "hi <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{user.id}\" href=\"#{user.ap_id}\" rel=\"ugc\">@<span>#{user.nickname}</span></a></span>"
assert [%{"status" => %{"content" => response}} | _rest] =
json_response_and_validate_schema(conn, 200)
assert response == expected_response
end
- test "by default, does not contain pleroma:chat_mention" do
- %{user: user, conn: conn} = oauth_access(["read:notifications"])
- other_user = insert(:user)
-
- {:ok, _activity} = CommonAPI.post_chat_message(other_user, user, "hey")
-
- result =
- conn
- |> get("/api/v1/notifications")
- |> json_response_and_validate_schema(200)
-
- assert [] == result
-
- result =
- conn
- |> get("/api/v1/notifications?include_types[]=pleroma:chat_mention")
- |> json_response_and_validate_schema(200)
-
- assert [_] = result
- end
-
test "by default, does not contain pleroma:report" do
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
assert [_] = result
end
- test "getting a single notification" do
+ test "excludes mentions from blockers when blockers_visible is false" do
+ clear_config([:activitypub, :blockers_visible], false)
+
%{user: user, conn: conn} = oauth_access(["read:notifications"])
- other_user = insert(:user)
+ blocker = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
+ {:ok, _} = CommonAPI.block(blocker, user)
+ {:ok, activity} = CommonAPI.post(blocker, %{status: "hi @#{user.nickname}"})
- {:ok, [notification]} = Notification.create_notifications(activity)
-
- conn = get(conn, "/api/v1/notifications/#{notification.id}")
+ {:ok, [_notification]} = Notification.create_notifications(activity)
- expected_response =
- "hi <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{user.id}\" href=\"#{
- user.ap_id
- }\" rel=\"ugc\">@<span>#{user.nickname}</span></a></span>"
+ conn =
+ conn
+ |> assign(:user, user)
+ |> get("/api/v1/notifications")
- assert %{"status" => %{"content" => response}} = json_response_and_validate_schema(conn, 200)
- assert response == expected_response
+ assert [] == json_response_and_validate_schema(conn, 200)
end
- test "dismissing a single notification (deprecated endpoint)" do
- %{user: user, conn: conn} = oauth_access(["write:notifications"])
+ test "getting a single notification" do
+ %{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
- conn =
- conn
- |> assign(:user, user)
- |> put_req_header("content-type", "application/json")
- |> post("/api/v1/notifications/dismiss", %{"id" => to_string(notification.id)})
+ conn = get(conn, "/api/v1/notifications/#{notification.id}")
- assert %{} = json_response_and_validate_schema(conn, 200)
+ expected_response =
+ "hi <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{user.id}\" href=\"#{user.ap_id}\" rel=\"ugc\">@<span>#{user.nickname}</span></a></span>"
+
+ assert %{"status" => %{"content" => response}} = json_response_and_validate_schema(conn, 200)
+ assert response == expected_response
end
test "dismissing a single notification" do