Allign datetime format with mastodon.
authorRoger Braun <rbraun@Bobble.local>
Wed, 13 Sep 2017 14:26:02 +0000 (16:26 +0200)
committerRoger Braun <rbraun@Bobble.local>
Wed, 13 Sep 2017 14:26:02 +0000 (16:26 +0200)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs

index dede0434db5d383c905b5ac746426d0978e932fd..8547606dece264ee7f5b110bb5160ddc7a1134c0 100644 (file)
@@ -158,6 +158,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     result = Enum.map(notifications, fn (%{id: id, activity: activity, inserted_at: created_at}) ->
       actor = User.get_cached_by_ap_id(activity.data["actor"])
       created_at = NaiveDateTime.to_iso8601(created_at)
+      |> String.replace(~r/\.\d+Z/, ".000Z")
       case activity.data["type"] do
         "Create" ->
           %{id: id, type: "mention", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), status: StatusView.render("status.json", %{activity: activity})}
index cc5c0e9b67aa9c416c2f6d3caa9c6cc75fbfba83..4a3ab7b505a1c730a64e7a8792cd5094fc3d03b6 100644 (file)
@@ -27,7 +27,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
     attachments = render_many(object["attachment"] || [], StatusView, "attachment.json", as: :attachment)
 
     created_at = (object["published"] || "")
-    |> String.replace(~r/\.\d+/, "")
+    |> String.replace(~r/\.\d+Z/, ".000Z")
 
     %{
       id: activity.id,
index 3c2de4cbea93835f7cdf2ad03c2c18faa9346d62..198ee72a88c58a719f75d52c6359ed803e1b51a9 100644 (file)
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     status = StatusView.render("status.json", %{activity: note})
 
     created_at = (note.data["object"]["published"] || "")
-    |> String.replace(~r/\.\d+/, "")
+    |> String.replace(~r/\.\d+Z/, ".000Z")
 
     expected = %{
       id: note.id,