Allign datetime format with mastodon.

This commit is contained in:
Roger Braun 2017-09-13 16:26:02 +02:00
parent d2faee01ee
commit 94be93aad0
3 changed files with 3 additions and 2 deletions

View 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})}

View 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,

View 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,