Merge branch 'develop' into notifications-from-account
authorEgor Kislitsyn <egor@kislitsyn.com>
Wed, 15 Jan 2020 12:49:45 +0000 (16:49 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Wed, 15 Jan 2020 12:49:45 +0000 (16:49 +0400)
1  2 
CHANGELOG.md
test/web/mastodon_api/controllers/notification_controller_test.exs

diff --cc CHANGELOG.md
Simple merge
index 24d0d49ed9bb21d148236d173715ce691850c6e5,86303f92f13602200f3d5e57b44807a130df46f5..38161982a7b4ed5932980aed3bafed3cb325fae1
@@@ -463,29 -425,38 +425,61 @@@ defmodule Pleroma.Web.MastodonAPI.Notif
      assert length(json_response(conn, 200)) == 1
    end
  
+   describe "link headers" do
+     test "preserves parameters in link headers" do
+       %{user: user, conn: conn} = oauth_access(["read:notifications"])
+       other_user = insert(:user)
+       {:ok, activity1} =
+         CommonAPI.post(other_user, %{
+           "status" => "hi @#{user.nickname}",
+           "visibility" => "public"
+         })
+       {:ok, activity2} =
+         CommonAPI.post(other_user, %{
+           "status" => "hi @#{user.nickname}",
+           "visibility" => "public"
+         })
+       notification1 = Repo.get_by(Notification, activity_id: activity1.id)
+       notification2 = Repo.get_by(Notification, activity_id: activity2.id)
+       conn =
+         conn
+         |> assign(:user, user)
+         |> get("/api/v1/notifications", %{media_only: true})
+       assert [link_header] = get_resp_header(conn, "link")
+       assert link_header =~ ~r/media_only=true/
+       assert link_header =~ ~r/min_id=#{notification2.id}/
+       assert link_header =~ ~r/max_id=#{notification1.id}/
+     end
+   end
 +  describe "from specified user" do
 +    test "account_id", %{conn: conn} do
 +      user = insert(:user)
 +      %{id: account_id} = other_user1 = insert(:user)
 +      other_user2 = insert(:user)
 +
 +      {:ok, _activity} = CommonAPI.post(other_user1, %{"status" => "hi @#{user.nickname}"})
 +      {:ok, _activity} = CommonAPI.post(other_user2, %{"status" => "bye @#{user.nickname}"})
 +
 +      assert [%{"account" => %{"id" => ^account_id}}] =
 +               conn
 +               |> assign(:user, user)
 +               |> get("/api/v1/notifications", %{account_id: account_id})
 +               |> json_response(200)
 +
 +      assert %{"error" => "Account is not found"} =
 +               conn
 +               |> assign(:user, user)
 +               |> get("/api/v1/notifications", %{account_id: "cofe"})
 +               |> json_response(404)
 +    end
 +  end
 +
    defp get_notification_id_by_activity(%{id: id}) do
      Notification
      |> Repo.get_by(activity_id: id)