update marker api

This commit is contained in:
Maksim Pechnikov 2019-10-30 23:49:05 +03:00
parent 1b82eb6d41
commit 209319c8d2
3 changed files with 18 additions and 16 deletions

View File

@ -10,8 +10,10 @@ def render("markers.json", %{markers: markers}) do
Map.put_new(acc, m.timeline, %{ Map.put_new(acc, m.timeline, %{
last_read_id: m.last_read_id, last_read_id: m.last_read_id,
version: m.lock_version, 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)
end end

View File

@ -28,9 +28,9 @@ test "gets markers with correct scopes", %{conn: conn} do
assert response == %{ assert response == %{
"notifications" => %{ "notifications" => %{
"last_read_id" => "69420", "last_read_id" => "69420",
"unread_count" => 7,
"updated_at" => NaiveDateTime.to_iso8601(marker.updated_at), "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
"version" => 0 "version" => 0,
"pleroma" => %{ "unread_count" => 7 }
} }
} }
end end
@ -72,7 +72,7 @@ test "creates a marker with correct scopes", %{conn: conn} do
"last_read_id" => "69420", "last_read_id" => "69420",
"updated_at" => _, "updated_at" => _,
"version" => 0, "version" => 0,
"unread_count" => 0 "pleroma" => %{ "unread_count" => 0 }
} }
} = response } = response
end end
@ -100,9 +100,9 @@ test "updates exist marker", %{conn: conn} do
assert response == %{ assert response == %{
"notifications" => %{ "notifications" => %{
"last_read_id" => "69888", "last_read_id" => "69888",
"unread_count" => 0,
"updated_at" => NaiveDateTime.to_iso8601(marker.updated_at), "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
"version" => 0 "version" => 0,
"pleroma" => %{ "unread_count" => 0 }
} }
} }
end end

View File

@ -14,15 +14,15 @@ test "returns markers" do
assert MarkerView.render("markers.json", %{markers: [marker1, marker2]}) == %{ assert MarkerView.render("markers.json", %{markers: [marker1, marker2]}) == %{
"home" => %{ "home" => %{
last_read_id: "42", last_read_id: "42",
unread_count: 0,
updated_at: NaiveDateTime.to_iso8601(marker2.updated_at), updated_at: NaiveDateTime.to_iso8601(marker2.updated_at),
version: 0 version: 0,
pleroma: %{unread_count: 0}
}, },
"notifications" => %{ "notifications" => %{
last_read_id: "17", last_read_id: "17",
unread_count: 5,
updated_at: NaiveDateTime.to_iso8601(marker1.updated_at), updated_at: NaiveDateTime.to_iso8601(marker1.updated_at),
version: 0 version: 0,
pleroma: %{unread_count: 5}
} }
} }
end end