Remove milliseconds from mastodon api response.
authorRoger Braun <roger@rogerbraun.net>
Tue, 12 Sep 2017 11:31:17 +0000 (13:31 +0200)
committerRoger Braun <roger@rogerbraun.net>
Tue, 12 Sep 2017 11:31:17 +0000 (13:31 +0200)
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs

index 895ab3d507fbccdee61255454c895dab40df3442..cc5c0e9b67aa9c416c2f6d3caa9c6cc75fbfba83 100644 (file)
@@ -26,6 +26,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
 
     attachments = render_many(object["attachment"] || [], StatusView, "attachment.json", as: :attachment)
 
+    created_at = (object["published"] || "")
+    |> String.replace(~r/\.\d+/, "")
+
     %{
       id: activity.id,
       uri: object["id"],
@@ -35,7 +38,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
       in_reply_to_account_id: nil,
       reblog: nil,
       content: HtmlSanitizeEx.basic_html(object["content"]),
-      created_at: object["published"],
+      created_at: created_at,
       reblogs_count: announcement_count,
       favourites_count: like_count,
       reblogged: !!repeated,
index 2eb27009b0c93886b3c1a017b7dada025e6d6cb6..3c2de4cbea93835f7cdf2ad03c2c18faa9346d62 100644 (file)
@@ -12,6 +12,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
 
     status = StatusView.render("status.json", %{activity: note})
 
+    created_at = (note.data["object"]["published"] || "")
+    |> String.replace(~r/\.\d+/, "")
+
     expected = %{
       id: note.id,
       uri: note.data["object"]["id"],
@@ -21,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       in_reply_to_account_id: nil,
       reblog: nil,
       content: HtmlSanitizeEx.basic_html(note.data["object"]["content"]),
-      created_at: note.data["object"]["published"],
+      created_at: created_at,
       reblogs_count: 0,
       favourites_count: 0,
       reblogged: false,