diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-09-10 17:46:43 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-09-10 17:49:13 +0200 |
commit | 7616b202ea6ab9cd2db107eea59aba1393f4f996 (patch) | |
tree | 2dc43321ca99fd351aab4e8d09a8d286d244ea9b /lib | |
parent | b8912ff954a0aa6426eb2205da82db8bee6c5a6a (diff) | |
download | pleroma-7616b202ea6ab9cd2db107eea59aba1393f4f996.tar.gz |
Add user timelines to Masto Api.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 15 | ||||
-rw-r--r-- | lib/pleroma/web/router.ex | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 1aa7f43ab..16ee434c6 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1,6 +1,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do use Pleroma.Web, :controller - alias Pleroma.{Repo, Activity} + alias Pleroma.{Repo, Activity, User} alias Pleroma.Web.OAuth.App alias Pleroma.Web alias Pleroma.Web.MastodonAPI.{StatusView, AccountView} @@ -55,6 +55,19 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do render conn, StatusView, "index.json", %{activities: activities, for: user, as: :activity} end + def user_statuses(%{assigns: %{user: user}} = conn, params) do + with %User{ap_id: ap_id} <- Repo.get(User, params["id"]) do + params = params + |> Map.put("type", "Create") + |> Map.put("actor_id", ap_id) + + activities = ActivityPub.fetch_activities([], params) + |> Enum.reverse + + render conn, StatusView, "index.json", %{activities: activities, for: user, as: :activity} + end + end + def get_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do with %Activity{} = activity <- Repo.get(Activity, id) do render conn, StatusView, "status.json", %{activity: activity, for: user} diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 5246b3c41..9e725641d 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -48,6 +48,8 @@ defmodule Pleroma.Web.Router do get "/statuses/:id", MastodonAPIController, :get_status get "/statuses/:id/context", MastodonAPIController, :get_context + + get "/accounts/:id/statuses", MastodonAPIController, :user_statuses end scope "/api/v1", Pleroma.Web.MastodonAPI do |