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 @@ def notifications(%{assigns: %{user: user}} = conn, params) do
result = Enum.map(notifications, fn (%{id: id, activity: activity, inserted_at: created_at}) -> result = Enum.map(notifications, fn (%{id: id, activity: activity, inserted_at: created_at}) ->
actor = User.get_cached_by_ap_id(activity.data["actor"]) actor = User.get_cached_by_ap_id(activity.data["actor"])
created_at = NaiveDateTime.to_iso8601(created_at) created_at = NaiveDateTime.to_iso8601(created_at)
|> String.replace(~r/\.\d+Z/, ".000Z")
case activity.data["type"] do case activity.data["type"] do
"Create" -> "Create" ->
%{id: id, type: "mention", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), status: StatusView.render("status.json", %{activity: activity})} %{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 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
attachments = render_many(object["attachment"] || [], StatusView, "attachment.json", as: :attachment) attachments = render_many(object["attachment"] || [], StatusView, "attachment.json", as: :attachment)
created_at = (object["published"] || "") created_at = (object["published"] || "")
|> String.replace(~r/\.\d+/, "") |> String.replace(~r/\.\d+Z/, ".000Z")
%{ %{
id: activity.id, id: activity.id,

View File

@ -13,7 +13,7 @@ test "a note activity" do
status = StatusView.render("status.json", %{activity: note}) status = StatusView.render("status.json", %{activity: note})
created_at = (note.data["object"]["published"] || "") created_at = (note.data["object"]["published"] || "")
|> String.replace(~r/\.\d+/, "") |> String.replace(~r/\.\d+Z/, ".000Z")
expected = %{ expected = %{
id: note.id, id: note.id,