update marker api
authorMaksim Pechnikov <parallel588@gmail.com>
Wed, 30 Oct 2019 20:49:05 +0000 (23:49 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Wed, 30 Oct 2019 20:49:05 +0000 (23:49 +0300)
lib/pleroma/web/mastodon_api/views/marker_view.ex
test/web/mastodon_api/controllers/marker_controller_test.exs
test/web/mastodon_api/views/marker_view_test.exs

index 1501c2a30fb07b16408b675214878125523f91c7..81545cff08e2b82166ce87b44c150829c0d09026 100644 (file)
@@ -10,8 +10,10 @@ defmodule Pleroma.Web.MastodonAPI.MarkerView do
       Map.put_new(acc, m.timeline, %{
         last_read_id: m.last_read_id,
         version: m.lock_version,
-        unread_count: m.unread_count,
-        updated_at: NaiveDateTime.to_iso8601(m.updated_at)
+        updated_at: NaiveDateTime.to_iso8601(m.updated_at),
+        pleroma: %{
+          unread_count: m.unread_count
+        }
       })
     end)
   end
index 5e7b4001f257e8009f16156f4e1af8aef1fdc11f..e0aacccb47c84fdc08106567460430323f4b7ea2 100644 (file)
@@ -26,13 +26,13 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
         |> json_response(200)
 
       assert response == %{
-               "notifications" => %{
-                 "last_read_id" => "69420",
-                 "unread_count" => 7,
-                 "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
-                 "version" => 0
-               }
-             }
+        "notifications" => %{
+          "last_read_id" => "69420",
+          "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
+          "version" => 0,
+          "pleroma" => %{ "unread_count" => 7 }
+        }
+      }
     end
 
     test "gets markers with missed scopes", %{conn: conn} do
@@ -72,7 +72,7 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
                  "last_read_id" => "69420",
                  "updated_at" => _,
                  "version" => 0,
-                 "unread_count" => 0
+                 "pleroma" => %{ "unread_count" => 0 }
                }
              } = response
     end
@@ -100,9 +100,9 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
       assert response == %{
                "notifications" => %{
                  "last_read_id" => "69888",
-                 "unread_count" => 0,
                  "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
-                 "version" => 0
+                 "version" => 0,
+                 "pleroma" => %{ "unread_count" => 0 }
                }
              }
     end
index 3ce794617f275f23c49925a5f6ef18421c053b69..f172e50235307abdec3c46a4363767489e91bd92 100644 (file)
@@ -14,15 +14,15 @@ defmodule Pleroma.Web.MastodonAPI.MarkerViewTest do
     assert MarkerView.render("markers.json", %{markers: [marker1, marker2]}) == %{
              "home" => %{
                last_read_id: "42",
-               unread_count: 0,
                updated_at: NaiveDateTime.to_iso8601(marker2.updated_at),
-               version: 0
+               version: 0,
+               pleroma: %{unread_count: 0}
              },
              "notifications" => %{
                last_read_id: "17",
-               unread_count: 5,
                updated_at: NaiveDateTime.to_iso8601(marker1.updated_at),
-               version: 0
+               version: 0,
+               pleroma: %{unread_count: 5}
              }
            }
   end