Return iso8601 date.
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index 219d860a9c7b0a7e29cccab1f0ef3a1992ad41ec..dede0434db5d383c905b5ac746426d0978e932fd 100644 (file)
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.TwitterAPI.TwitterAPI
   alias Pleroma.Web.CommonAPI
+  import Ecto.Query
   import Logger
 
   def create_app(conn, params) do
@@ -156,6 +157,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     notifications = Notification.for_user(user, params)
     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)
       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})}
@@ -177,6 +179,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     |> json(result)
   end
 
+  def relationships(%{assigns: %{user: user}} = conn, %{"id" => id}) do
+    id = List.wrap(id)
+    q = from u in User,
+      where: u.id in ^id
+    targets = Repo.all(q)
+    render conn, AccountView, "relationships.json", %{user: user, targets: targets}
+  end
+
   def empty_array(conn, _) do
     Logger.debug("Unimplemented, returning an empty array")
     json(conn, [])