Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85832397
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/changelog.d/marker-updated-at-format.fix b/changelog.d/marker-updated-at-format.fix
new file mode 100644
index 000000000..2ff681525
--- /dev/null
+++ b/changelog.d/marker-updated-at-format.fix
@@ -0,0 +1 @@
+Mastodon API: Use the Mastodon date format for marker updated_at
diff --git a/lib/pleroma/web/mastodon_api/views/marker_view.ex b/lib/pleroma/web/mastodon_api/views/marker_view.ex
index 944769b1a..fd067f713 100644
--- a/lib/pleroma/web/mastodon_api/views/marker_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/marker_view.ex
@@ -5,13 +5,15 @@
defmodule Pleroma.Web.MastodonAPI.MarkerView do
use Pleroma.Web, :view
+ alias Pleroma.Web.CommonAPI.Utils
+
def render("markers.json", %{markers: markers}) do
Map.new(markers, fn m ->
{m.timeline,
%{
last_read_id: m.last_read_id,
version: m.lock_version,
- updated_at: NaiveDateTime.to_iso8601(m.updated_at),
+ updated_at: Utils.to_masto_date(m.updated_at),
pleroma: %{
unread_count: m.unread_count
}
diff --git a/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
index 4050528ff..ff85031f0 100644
--- a/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
@@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
alias Pleroma.Notification
alias Pleroma.Repo
alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.CommonAPI.Utils
import Pleroma.Factory
@@ -33,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
assert response == %{
"notifications" => %{
"last_read_id" => "69420",
- "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
+ "updated_at" => Utils.to_masto_date(marker.updated_at),
"version" => 0,
"pleroma" => %{"unread_count" => 7}
}
@@ -107,7 +108,7 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
assert response == %{
"notifications" => %{
"last_read_id" => "69888",
- "updated_at" => NaiveDateTime.to_iso8601(marker.updated_at),
+ "updated_at" => Utils.to_masto_date(marker.updated_at),
"version" => 0,
"pleroma" => %{"unread_count" => 0}
}
diff --git a/test/pleroma/web/mastodon_api/views/marker_view_test.exs b/test/pleroma/web/mastodon_api/views/marker_view_test.exs
index 43f8c4302..4f4eeca82 100644
--- a/test/pleroma/web/mastodon_api/views/marker_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/marker_view_test.exs
@@ -4,6 +4,7 @@
defmodule Pleroma.Web.MastodonAPI.MarkerViewTest do
use Pleroma.DataCase, async: true
+ alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.MarkerView
import Pleroma.Factory
@@ -14,16 +15,25 @@ defmodule Pleroma.Web.MastodonAPI.MarkerViewTest do
assert MarkerView.render("markers.json", %{markers: [marker1, marker2]}) == %{
"home" => %{
last_read_id: "42",
- updated_at: NaiveDateTime.to_iso8601(marker2.updated_at),
+ updated_at: Utils.to_masto_date(marker2.updated_at),
version: 0,
pleroma: %{unread_count: 0}
},
"notifications" => %{
last_read_id: "17",
- updated_at: NaiveDateTime.to_iso8601(marker1.updated_at),
+ updated_at: Utils.to_masto_date(marker1.updated_at),
version: 0,
pleroma: %{unread_count: 5}
}
}
end
+
+ test "renders updated_at in the Mastodon date format" do
+ marker = insert(:marker, timeline: "home")
+
+ %{"home" => %{updated_at: updated_at}} =
+ MarkerView.render("markers.json", %{markers: [marker]})
+
+ assert updated_at =~ ~r/\.\d{3}Z$/
+ end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 2, 8:18 AM (16 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1803769
Default Alt Text
(3 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline